表中有10个字段,其中6个字段可为空,我想统计这6个字段中空的字段数;不知如何解决;
我写了个sql但报错“未找到预期FROM关键字”select count1=(case when 字段1 is null then 1 else 0 and 
case when 字段2 is null then 1 else 0 and ......) from 表请各位高手帮忙解决,谢谢了!

解决方案 »

  1.   

    select sum((case when 字段1 is null then 1 else 0 end)) as count1,
           sum((case when 字段2 is null then 1 else 0 end)) as count2,
           sum((case when 字段3 is null then 1 else 0 end)) as count3,  
           sum((case when 字段4 is null then 1 else 0 end)) as count4, 
           sum((case when 字段5 is null then 1 else 0 end)) as count5,  
           sum((case when 字段6 is null then 1 else 0 end)) as count6    from 表