Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14 lines (14 sloc)
446 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*What is the average number of orders per day?*/ | |
SELECT AVG( orders_num ) | |
FROM ( | |
SELECT created_at, COUNT( DISTINCT order_id ) orders_num | |
FROM `sales_flat_order_item` | |
GROUP BY CAST( created_at AS DATE ) | |
)orders_per_day | |
/*What is the average number of orders per month?*/ | |
SELECT AVG( orders_num ) | |
FROM ( | |
SELECT created_at, COUNT( DISTINCT order_id ) orders_num | |
FROM `sales_flat_order_item` | |
GROUP BY MONTH( created_at ) | |
)orders_per_month |