开发者

mysql views my query output i need different manner

This is my query

Select Count(Case When campaign_pid != 0 Then 1 End) As Email,
  Count(Case When sms_pid != 0 Then 1 End) As Sms,
  Count(Case When survey_pid != 0 Then 1 End) As Survey
From tablename  

Please help me This is my query output

Email   Sms     Survey    
21     1       4

i need output like this

 name    开发者_运维问答value  
 Email   21  
 Sms     1   
 Survey  4

Please tell me how to get like above optput


TRY

SELECT COUNT(Case WHEN campaign_pid != 0 THEN 1 END) AS Email FROM tablename
UNION
SELECT COUNT(Case WHEN sms_pid != 0 THEN 1 END) As Sms FROM tablename
UNION
SELECT COUNT(Case WHEN survey_pid != 0 THEN 1 END) As Survey FROM tablename

Reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜