晚上关节痛吃姜片:select distinct id ,num=sum(cast((num) as int) from sy order by id desc

来源:百度文库 编辑:中科新闻网 时间:2024/05/10 08:12:45
有什么地方错了,指出谢谢!

应该分组查询
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 是保留字。换个名字试试