刚用到count中用distinct多个字段,找到了下面这条语句,记录一下
查询出全部记录数
SELECT COUNT(*) FROM (SELECT DISTINCT checkpart,bug FROM carInfor) A
查询出checkpart,bug每个相同有多少条记录
select count(*) from carInfor group by checkpart,bug
比较全的语句:
select checkpart,bug,count(*) as amount
from v_carInfor where bug!='合格' and checkdate='2011-02-14'
group by checkpart,bug order by amount desc