子查詢
更新時間:
以下示例查詢門票銷量排名前10的賣家,WHERE
子句中包含一個表子查詢,子查詢生成多個行,每行包含一列數(shù)據(jù)。
說明
表子查詢可以包含多個列和行。
select firstname, lastname, cityname, max(qtysold) as maxsold
from users join sales on users.userid=sales.sellerid
where users.cityname not in(select venuecity from venue)
group by firstname, lastname, cityname
order by maxsold desc, cityname desc
limit 10;
firstname | lastname | cityname | maxsold
-----------+----------+----------------+---------
Noah | Guerrero | Worcester | 8
Isadora | Moss | Winooski | 8
Kieran | Harrison | Westminster | 8
Heidi | Davis | Warwick | 8
Sara | Anthony | Waco | 8
Bree | Buck | Valdez | 8
Evangeline | Sampson | Trenton | 8
Kendall | Keith | Stillwater | 8
Bertha | Bishop | Stevens Point | 8
Patricia | Anderson | South Portland | 8
文檔內(nèi)容是否對您有幫助?