SQL COUNT(DISTINCT(field1)) GROUP BY MAX(filed2)
SQL COUNT(DISTINCT(field1)) GROUP BY MAX(filed2)
我有一个table喜欢
name num_try
John 2
John 1
Mike 3
Mike 2
Linda 2
我想知道按 MAX(num_try)
.
对不同名称进行分组
想要的结果应该是这样的
MAX(num_try) COUNT(DISTINCT(names))
2 2
3 1
你能帮我解决这个问题吗?
select max_num_try, count(*) from
(
select name, max(num_try) as max_num_try
from table1
group by name
) a
group by max_num_try
order by max_num_try desc
我有一个table喜欢
name num_try
John 2
John 1
Mike 3
Mike 2
Linda 2
我想知道按 MAX(num_try)
.
想要的结果应该是这样的
MAX(num_try) COUNT(DISTINCT(names))
2 2
3 1
你能帮我解决这个问题吗?
select max_num_try, count(*) from
(
select name, max(num_try) as max_num_try
from table1
group by name
) a
group by max_num_try
order by max_num_try desc