我有一个查询A,结果是:
orders | date_added
10 | 2013-01-09
24 | 2013-01-10
13 | 2013-01-11
我希望获得对应日期的最大订单数量。 这是我到目前为止的查询
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"
答案 0 :(得分:1)
我认为这会解决这个问题
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