哪位高手可以帮小弟我解答这个Query的有关问题?多谢
谁可以帮我解答这个Query的问题??谢谢
总共2个table
Sample table1: <--名字是customer
customerID customerName
1 sima
2 melven
3 spidey
4 anna
5 squallsoh
Sample 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)
------解决方案--------------------
总共2个table
Sample table1: <--名字是customer
customerID customerName
1 sima
2 melven
3 spidey
4 anna
5 squallsoh
Sample 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)
------解决方案--------------------
- SQL code
select o.customerID,c.customerID,count(*) from orders o inner join customer c on o.customerID=c.customerID group by o.customerID,c.customerID order by 2 desc limit 1