Reputation: 2022
I have a query A that results in :
orders | date_added
10 | 2013-01-09
24 | 2013-01-10
13 | 2013-01-11
I want to get the max number of orders with the corresponding date .. Here's my query so far
SELECT MAX( orders )
FROM (
SELECT COUNT( order_id ) AS orders, DATE( date_added ) FROM `order`
WHERE YEAR(date_added) = YEAR( NOW( ) )
GROUP BY DATE( date_added )
) AS daily_orders"
Upvotes: 0
Views: 269
Reputation: 1094
I think this will solve this
SELECT COUNT( order_id ) AS orders, DATE( date_added ) FROM `order`
WHERE YEAR(date_added) = YEAR( NOW( ) )
GROUP BY DATE( date_added )
ORDER BY orders DESC LIMIT 1
Upvotes: 1