Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Format for Query Defined Field

I have the following query in iSeries SQL which 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 field created be the sum(SSCOUNT) is a 31 Packed field. This does not allow me to send it to my PC. How can I force SQL to create the field as a non-packed field.

like image 934
David Avatar asked Dec 03 '25 20:12

David


1 Answers

Try this

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've casted to integer because of the name of the column "count". If the column has floating-point values you can use numeric(8, 2) instead.

like image 92
pmg Avatar answered Dec 06 '25 13:12

pmg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!