现有一个表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