--numeric可以指定保留的小数位数 select cast(12.3456 as numeric(6,2))
SELECT cuku_goodsinf.col_bh, cuku_goodsinf.col_htbh, cuku_goodsinf.col_cpbh, SUM(CAST(cuku_goodsinf.col_lysl AS numeric(10,2))) AS outsl FROM cuku_goodsinf WHERE 1=1 GROUP BY cuku_goodsinf.col_bh出错: Server: Msg 8120, Level 16, State 1, Line 1 Column 'cuku_goodsinf.col_htbh' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Server: Msg 8120, Level 16, State 1, Line 1 Column 'cuku_goodsinf.col_cpbh' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
select cast(12.3456 as numeric(6,2))
SUM(CAST(cuku_goodsinf.col_lysl AS numeric(10,2))) AS outsl
FROM cuku_goodsinf
WHERE 1=1
GROUP BY cuku_goodsinf.col_bh出错:
Server: Msg 8120, Level 16, State 1, Line 1
Column 'cuku_goodsinf.col_htbh' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Server: Msg 8120, Level 16, State 1, Line 1
Column 'cuku_goodsinf.col_cpbh' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.