在德勤工作:select distinct id ,num=sum(cast((num) as int) from sy order by id desc

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 18:38:56
有什么地方错了,指出谢谢!

应该分组查询
select distinct id ,Totalnum=count(num)
from sy group by id order by id desc

如果num不是int可以
select distinct id ,nums=count(cast((num) as int)
from sy group by id order by id desc

sum(cast((num) as int)
int 是保留字。换个名字试试