sql语句:如何查数据库一个表中的一个行的不同项

[复制链接]
查看11 | 回复4 | 2017-10-13 14:52:26 | 显示全部楼层 |阅读模式
查数据库一个表中的一个行的不同项,肯定要用到【Group By】语法。示例1:查询A列,在表Table_temp中不同项select A from Table_temp group by a示例2:查询A列,在表Table_temp中不同项出现的次数select A,count(0) as 出现次数 from Table_temp group by a...
回复

使用道具 举报

千问 | 2017-10-13 14:52:26 | 显示全部楼层
select count(distinct ITEM1) from 表1就能得出个数啦。...
回复

使用道具 举报

千问 | 2017-10-13 14:52:26 | 显示全部楼层
select t.item1, count(*) from 表1 tgroup by t.item1...
回复

使用道具 举报

千问 | 2017-10-13 14:52:26 | 显示全部楼层
select max(case t.item1 when 'aa' then count(t.item1) else 0 end) aa,max(case t.item1 when 'bb' then count(t.item1)else 0 end) bb,max(case t.item1 when 'cc' then count(...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行