mysql - pivot table: getting data from one column -


lets 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, means accept. beside want show result like:

date         accept            reject       2010-01-02    1                 0 2010-01-03    3                 1 2010-01-04    0                 1 

it means, calculate amount of either accept or reject contained in status column. how do that?

select date date, sum( if(  status =  'accept', 1, 0 ) ) accept, sum( if(  status =  'reject', 1, 0 ) ) reject pivot group date 

updated** , working


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -