I have the following two tables as a part of my order processing system:
order(id, date)
order_item(order_id, item_id, type)
The type is an enum which denotes which table to look the order_item up in.
I want to write a query that selects the number of different item types ordered on each day. So it should produce something like:
Date tshirts dvds mugs cds
07/07/2010 3 6 2 2
10/07/2010 4 9 3 1
13/07/2010 1 2 1 9
Here is the query I currently have to select the count for one type. I just can't work out how to extend it to select the counts for multiple types.
SELECT DATE(order.date), COUNT(order.date)
FROM order, order_item
WHERE order.id = order_item.order_id AND order_item.type = 'tshirts'
GROUP BY DATE(order.date)