I have the following db table, and I would like to be able to count amount of each product_id per name.
--------------------- | name | product_id | --------------------- | David | 1 | |Charlie| 1 | | David | 2 | | David | 1 | |Charlie| 2 | |Charlie| 3 | |Charlie| 2 | |Charlie| 3 | ---------------------
I would like to able to create a result set like the following;
---------------------------------------------------------------------------- | name | count(product_id_1) | count(product_id_1) | count(product_id_1) | ---------------------------------------------------------------------------- | David | 2 | 1 | 0 | |Charlie | 1 | 2 | 2 | ----------------------------------------------------------------------------
So, please help me how to query for the above problem, Thank's