在sql的orders表中检索2009年哪些客户的订单数量最多的语句怎么写,求大神指导!
select customerid,count(*)as 'n' from Orders
where 'n'=(select max('n') from Orders) and YEAR(OrderDate)=2009
group by CustomerID
我这样写检索出了87行,怎么办呀?小白求教!!
按照年份筛选,通过用户id分组,然后使用sum进行统计并且倒序排序即可
热门标签:
select customerid,count(*)as 'n' from Orders
where 'n'=(select max('n') from Orders) and YEAR(OrderDate)=2009
group by CustomerID
我这样写检索出了87行,怎么办呀?小白求教!!
按照年份筛选,通过用户id分组,然后使用sum进行统计并且倒序排序即可