0

我有一个查询 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"
4

1 回答 1

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
于 2013-05-18T08:39:17.570 回答