Sql Query to get total rows and total rows matching specific condition
        Posted  
        
            by 
                mrNepal
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mrNepal
        
        
        
        Published on 2011-01-12T06:45:57Z
        Indexed on 
            2011/01/12
            6:53 UTC
        
        
        Read the original article
        Hit count: 291
        
mysql
OK, Here is what my table looks like
------------------------------------------------
id                     type
-----------------------------------------------
1                      a
2                      b
3                      a
4                      c
5                      c
7                      a
8                      a
------------------------------------------------
Now, I need a query that can give me this output...
-----------------------------------------------------------------
count(*)   |   count(type=a)   | count(type=b)  | count(type=c)
-----------------------------------------------------------------
8                  4                 1               3
------------------------------------------------------------------
I only know to get the total set using count(*), but how to do the remaining
© Stack Overflow or respective owner