开发者

pivot table: getting data from one column

lets say my table like:

Date                   Status
2010-01-02            
2010-01-03             accept
2010-01-03             accept
2010-01-03             reject
2010-01-03
2010-01-04             reject

i want if value null, it means accept. Beside that i want show the result like:

Date         Accept            Reject      
2010-01-02    1                 0
201开发者_如何学运维0-01-03    3                 1
2010-01-04    0                 1

it means, calculate the amount of either accept or reject which contained in the status column. How do i do that?


SELECT DATE AS DATE, SUM( IF( 
STATUS =  'accept', 1, 0 ) ) AS Accept, SUM( IF( 
STATUS =  'reject', 1, 0 ) ) AS Reject
FROM pivot
GROUP BY DATE

updated** and working

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜