例如我们锚定student_id
select count(1),
count(distinct student_id) ----注意distinct 的重要使用
from
abc.table_student;
不一致那么就有重复值,会出现一对多,一个id多条信息
或者:
select student_id,count(1) from abc.table_student
group by student_id
having count(1)>=2;
count(1)的作用,就是统计在分组中,每一组对应的行数或项数。效率和作用和count(*)相同。
Count()中的表达式是否为NULL,如果为NULL则不计数,而非NULL则会计数。