SQL如何先用group by分组,并将分组的结果distinct?

2025-03-25 20:50:40
推荐回答(2个)
回答1:

select tag, count(distinct(id)) from table_name group by tag;    mysql里执行正确

模拟数据:

操作结果:

回答2:

select tag,count(id)
from table
group by tag;