select code,id,from t group by code --------你这条语句能执行成功?把你的表结构、测试数据和最终想要的数据贴出来吧
select distinct id from t
select count(distinct id) from t
select code,count(distinct id) from t group by code
写错了是:select code,id,from t order by code我已经想到了方法:select code,count(*) from (select distinct id,code from t order by code) a 不知道有没有更效率的写法
按code分组? 那就select code,count(distinct id) from t group by code order by code
select code,count(*) from (select distinct id,code from t order by code) a ----你这句也不行。select code,count(distinct id) from t group by code order by code 不知道这是不是你想要的结果。。
--------你这条语句能执行成功?把你的表结构、测试数据和最终想要的数据贴出来吧
那就select code,count(distinct id) from t group by code order by code
----你这句也不行。select code,count(distinct id) from t group by code order by code
不知道这是不是你想要的结果。。
qin_phoenix、wildwave、liusong_china都能实现。