当前位置: 代码迷 >> Sql Server >> sql统计,该如何解决
  详细解决方案

sql统计,该如何解决

热度:105   发布时间:2016-04-27 19:15:30.0
sql统计
现有一个表test 
id job name
1 主任 小强
1 组长 小强
1 出纳 小芳
1 前台 小华
1 主管 小刘
1 副经理 小刘

我现在要统计test表的去除重复人数 正确结果4个人,就是说重复的名字我算一次
这个统计sql语句怎么写呢?

------解决方案--------------------
SQL code
select count(distinct Name) from test
------解决方案--------------------
SQL code
select * from test a whrere not exists(select 1 from test where name=a.name and job>a.job)
------解决方案--------------------
SQL code
select count(distinct Name) from test
------解决方案--------------------
SQL code
select count(distinct name ) from tb
  相关解决方案