I have the following table:
order_id product_id
1 102
2 105
3 102
4 96
5 96
How would I get a count of the product_id
s. The result I am looking to attain is:
product_id count
96 2
102 2
105 1
The query I have tried is:
SELECT product_id, sum(product_id) from orders
But this of course produces an incorrect result with only one row. What would be the correct query here?