The SQL to get total order number and total order amount from orders table:
SELECT count(*), sum(order_total)FROM ordersWHERE DAYOFMONTH(last_accessed) = DAYOFMONTH(now())AND MONTH(last_accessed) = MONTH(now())AND YEAR(last_accessed) = YEAR(now())AND record_state = 1
Note:
- DAYOFMONTH is synonym of DAY used to get day (ex: 1-31) from a data and time string (ex: 2009-04-14 11:44:02)
- Complete mysql date function can be found at here
No comments:
Post a Comment