首页 > 这条mysql语句该怎么写?

这条mysql语句该怎么写?

我想完成这样一个查询:数据表根据字段A进行分组后的总行数
意思大概等于下面这样两条语句顺序执行:

select A into tmp_table from table group by A
select count(*) from tmp_table

其中这个tmp_table并不存在,我瞎编的,我想一条语句实现不知道怎么写?


select count(1) from(
select count(1) , name from tf_user
group by name) as cnt_tf_user

tf_user表按照name字段分组,然后将查询结果作为表cnt_tf_user,最后从cnt_tf_user中查询出总条数。


你想要这个?

select count(distinct A) from table
【热门文章】
【热门文章】