我是这样写的:(sl是数量,bm是编码)
select sum(sl) as ss from sell where (bm in (select bm from sell group by bm having count(*)>1))
错误提示:sum or average aggregate 运算不能以 nvarchar 数据类型作为参数。
select sum(sl) as ss from sell where (bm in (select bm from sell group by bm having count(*)>1))
错误提示:sum or average aggregate 运算不能以 nvarchar 数据类型作为参数。
那么我在程序里需要动态获取编码号,用以上的sql语句即使正确也是统计出相同bm的数量和,那么如何分类查呢,也就是说如何让bm=1,bm=2,bm=3?
select sum(sl) as ss from sell where (bm in (select bm from sell group by bm having count(*)>1 where bm=1))这样写对不对?
这个语句不对的啊。另你的sum函数也不能那样使用。你的s1字段是nvarchar类型的,