总共2个table
Sample table1: <--名字是customer
customerID customerName
1 sima
2 melven
3 spidey
4 anna
5 squallsohSample table2: <--名字是orders
orderID customerID orderItem
1 2 pen
2 2 rubber
3 1 pen
4 2 books
5 5 books
Task: write an SQL query to identify which customer has the most orders in the systems
(找出那个customer下了最多的order)
Sample table1: <--名字是customer
customerID customerName
1 sima
2 melven
3 spidey
4 anna
5 squallsohSample table2: <--名字是orders
orderID customerID orderItem
1 2 pen
2 2 rubber
3 1 pen
4 2 books
5 5 books
Task: write an SQL query to identify which customer has the most orders in the systems
(找出那个customer下了最多的order)
from orders o inner join customer c on o.customerID=c.customerID
group by o.customerID,c.customerID
order by 2 desc
limit 1
[align=center]==== 思想重于技巧 ====
[/align]
limit 1 限制输出记录数,仅1条记录,也就是最大的那条[align=center]==== 思想重于技巧 ====
[/align]