[vox-tech] MySQL question: making stats out of orders

Bill Kendrick nbs at sonic.net
Tue Dec 1 17:39:14 PST 2009


On Tue, Dec 01, 2009 at 05:32:20PM -0800, Bill Kendrick wrote:
> Anyone feel like flexing their MySQL muscles and provide some
> ideas on how to populate a similar table (tracking sales) based
> on the orders/orderitem table combo explained above?
> 
> Thanks.  Sorry for asking you to do my (home)work for me.

Maybe as simple as something like:

SELECT
  orderitem.productid,
  SUM(orderitem.qty),
  FROM_DAYS(TO_DAYS(orders.ordertime)) AS day
FROM orders
JOIN orderitem ON orders.id = orderitem.orderid
GROUP BY productid,day

???

-bill!


More information about the vox-tech mailing list