取重复数据 在线等

luluyy 2015-10-10 09:46:40

列1 列2 列3 名称 规格 列6
1 2 4 b 100 6
3 7 9 b 200 9
8 9 5 c 100 7
5 6 3 c 100 9



sql语句 从上个表A中根据列4与列5两个条件取出重复数 并计算出各种重复的有多少条

得出的结果如下

条数 名称 规格
1 b 100
1 b 200
2 c 100
...全文
230 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_17144723 2015-10-27
  • 打赏
  • 举报
回复
select 1 as a, 2 as b, 4 as c, 'b' as name, 100 as spec, 6 as f into table1 select * from table1 insert into table1(a,b,c,name,spec,f) select 3, 7, 9, 'b', 200, 9 union all select 8, 9, 5, 'c', 100, 7 union all select 5, 6, 3, 'c', 100, 9 select * from table1 select count(*) as numcount,name,spec from table1 group by name,spec order by name,spec drop table table1
qq_17144723 2015-10-26
  • 打赏
  • 举报
回复
select count(t.*) as 条数,t.名称,t.规格 from (select distinct 名称,规格 from 表A) as t group by t.名称,t.规格
卖水果的net 2015-10-10
  • 打赏
  • 举报
回复

-- ?? 
select  名称      , 规格 , count (*) as 条数
from t 
group by  名称     ,  规格

27,582

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧