分组是必须的,在分组的情况下对符合条件的CLASS进行整个的不重复计数。
或者能先把CLASS这一列去掉,能在查询中再插一列做为新列也行要么不加WorkSubstance分组,只COUNT,要么不去count(DistinctClass),直接COUNTselectcount(DistinctClass)asClassfromClassDatewhereMachine='020-C03'andDateTime='2014-7-18'。
select fdate,sum(case when res='合格' then 1 else 0 end ) as '合格',sum(case when res='不合格' then 1 else 0 end ) as '不合格' from test group by fdate order by fdate欢迎分享,转载请注明来源:内存溢出
评论列表(0条)