±ÈÈçÒ»¸ö±íÓÐa,b,c,d£¬e 5¸ö×Ö¶Î ·µ»Ø a=1,b=1,d=1µÄ¼Ç¼Êý·Ö±ðÓжàÉÙ¸ö¡£·µ»ØÒ»¸öÒ»ÐеÄtableSQL code: select id='a',¼Ç¼Êý=count(*) from table where a=1 union all select id='b',¼Ç¼Êý=count(*) from table where b=1 union all select id='d',¼Ç¼Êý=count(*) from table where d=1
select a=Sum(case a when 1 then 1 else 0), b=Sum(case b when 1 then 1 else 0), c=Sum(case c when 1 then 1 else 0) from tb select a=Sum(case a when 1 then 1 else 0 end), b=Sum(case b when 1 then 1 else 0 end ), c=Sum(case c when 1 then 1 else 0 end ) from tb ¸Õ²ÅÉÙ¸öend ÉÏÃæÁ½ÖÖ¶¼ÐУ¬¸öÈ˱ȽÏϲ»¶£±Â¥ÕâÖÖ¡£ 1Â¥×ÝÏòÅÅÁÐ 2Â¥ºáÏòÅÅÁÐ ²»¶Ïѧϰ ѧϰ select Èý¸öͳ¼ÆºÃµÄÊý¾ÍÐÐÁ