I want to get the count of rows for each distinct value in column A grouped by column B like this:
------------------------------------------------------
| B | AValue1 | AValue2 | Avalue3 | AValue4 | ...... |
------------------------------------------------------
|B1 | x | x | x | x | x |
|B2 | x | x | x | x | x |
|...| x | x | x | x | x |
-------------------------------------------------------
x being the different counts. Right now i am getting basically the same data using "Group By(A,B)" but it is in the form:
----------------------------------------------
| A | B | Count |
----------------------------------------------
| AValue1 | BValue1 | x |
| ... | .... | x |
----------------------------------------------
after which i have to transform the Data in PHP or on the client in Javascript. The only way i could come up with to get the first table would be to do a subquery select for each of the values in A, but that defeats the purpose of it being a simpler and cleaner solution. Is there an easy way to achieve this in SQL or is transformation of the Group By table the best approach? Thanks in Advance