--显示商品编码重复的select a.* 
from 表 a,(select 商品编码 group by 商品编码 having count(*)>1) b
where a.商品编码=b.商品编码

解决方案 »

  1.   

    --所有的记录数量加起来
    select 数量=sum(数量) from 表
    --按商品编码分类加数量
    select 商品编码,数量=sum(数量) from 表 group by 商品编码
      

  2.   

    select 商品编码, 合计数量=sum(数量) 
    from 表
    group by 商品编码
      

  3.   

    1.select 商品编码,数量,b.AA from table a  right join  (select count(商品编码),商品编码,数量 as AA  from table 
    group by 商品编码,数量) b 
    on  a.商品编码 = b.商品编码 and a.数量 = b.数量  
    where b.AA <>1
    2.select 商品編碼,sum(數量) from YourTable group by 商品編碼
      

  4.   

    1.顯示重復的
    select 商品编码,数量,b.AA from table a  right join  (select count(商品编码) as AA  ,商品编码,数量 from table 
    group by 商品编码,数量) b 
    on  a.商品编码 = b.商品编码 and a.数量 = b.数量  
    where b.AA <>1
    2.
    所有的记录数量加起来
    (1)  select 数量=sum(数量) from 表(2)select 商品編碼,sum(數量) from YourTable group by 商品編碼