Q: Query To Get Sold Items & Quantities, In Period Of Time I have 2 tables, contains orders, & orders contents (i.e.,orders table, & o_contents), & I'd like to get statistics from these two tables, to see the sold quantities during an interval, a month, week, year, or even yesterday!
here are the tables fields:

orders table:
----------------
orderID
customerID
total
pmnt
orderDate
orderStatus

o_contents table
----------------
oContentsID
orderID
goodsID
goodsName
quantity
price

how can get statistics of items (goodsName) sold during an specific period in past (i.e, last month, last week, or even yesterday)

A: SELECT ocs.goodsName FROM orders os, o_contents ocs WHERE os.orderID = ocs.orderID AND os.orderDate between '2011-04-04' AND '2011-05-04'

A: SELECT o_contents.goodsName, 
       count(orders.orderID) 
FROM orders 
LEFT JOIN (o_contents) ON (orders.orderID = o_contents.orderID) 
GROUP BY MONTH(DATE_SUB(orders.orderDate, INTERVAL 1 MONTH))

This should show you how many of each good name have been sold in the previous month, just as an example. You can use the MYSQL date and time functions to define your own GROUP granularity:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

A: SELECT o_contents.goodsName FROM orders LEFT JOIN o_contents
ON orders.orderID = o_contents.orderID
WHERE orders.orderDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)

