我在输出到文件的iSeries SQL中有以下查询。
SELECT SSLOTMAK, SSLOTMDL, SSLOTYER, sum(SSCOUNT)
FROM prqhdrss
GROUP BY SSLOTMAK, SSLOTMDL, SSLotyer
HAVING sum(SSCOUNT) > 4
ORDER BY SSLOTMAK, SSLOTMDL, SSLOTYER
当我运行它时,创建的字段为sum(SSCOUNT)是一个31 Packed字段。这不允许我将其发送到PC。如何强制SQL将字段创建为非打包字段。
最佳答案
试试这个
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
由于列“ count”的名称,我将其强制转换为整数。如果该列具有浮点值,则可以改用
numeric(8, 2)
。关于sql - 设置查询定义字段的格式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/176625/