mysql统计distinct之后的记录总数
(2013-04-15 07:42:27)分类: linux命令 |
有多个学校+教师投稿,需要统计出作者的总数
select count(author) as total from files
每个作者都投稿很多,这里有重复的记录。
select distinct author from files;
有可能两个学校的教师姓名相同,结果只统计一个,出错。
select distinct author,sid from files
统计(作者+学校id)的组合唯一值,结果出现正确的结果,但如何知道一共有多少人呢?
select count(distinct author,sid) as total from files
解决!
前一篇:mysql远程连接不上
后一篇:使应用程序具有root运行权限