首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

哪位高手可以帮小弟我解答这个Query的有关问题?多谢

2012-03-14 
谁可以帮我解答这个Query的问题??谢谢总共2个tableSample table1:--名字是customercustomerIDcustomerNam

谁可以帮我解答这个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)


[解决办法]


SQL code
select o.customerID,c.customerID,count(*)from orders o inner join customer c on o.customerID=c.customerIDgroup by o.customerID,c.customerIDorder by 2 desclimit 1 

热点排行