Setting format for the field defined by the request

I have the following query in iSeries SQL that I output to a file.

SELECT SSLOTMAK, SSLOTMDL, SSLOTYER, sum(SSCOUNT)       
FROM prqhdrss                                                      
GROUP BY SSLOTMAK, SSLOTMDL, SSLotyer 
HAVING sum(SSCOUNT) > 4 
ORDER BY SSLOTMAK, SSLOTMDL, SSLOTYER                                    

When I run it, the created field will be the sum (SSCOUNT) - this is the 31 Packed field. This does not allow me to send it to a computer. How to force SQL to create a field as an unpacked field.

+3
source share
2 answers

try it

SELECT SSLOTMAK, SSLOTMDL, SSLOTYER, cast(sum(SSCOUNT) as integer)
FROM prqhdrss
GROUP BY SSLOTMAK, SSLOTMDL, SSLotyer
HAVING sum(SSCOUNT) > 4
ORDER BY SSLOTMAK, SSLOTMDL, SSLOTYER

I chose an integer because of the column name "count". If the column has floating point values, you can use instead numeric(8, 2).

+3
source

How are you trying to bring it to your computer? Most of the iSeries methods that I know automatically convert them to a computer readable format.

0
source

Source: https://habr.com/ru/post/1697958/


All Articles