where嵌套select_Select子查询:Select Zoo
針對Select Zoo題庫平臺,這次做的是select專題的練習SELECT within SELECT Tutorial和測試Nested SELECT Quiz。
一、SELECT within SELECT Tutorial:
SELECT within SELECT Tutorial?sqlzoo.net題目描述:
1、Bigger than Russia:
2、Richer than UK:
3、Neighbours of Argentina and Australia:
4、Between Canada and Poland:
5、Percentages of Germany:
6、Bigger than every country in Europe:
7、Largest in each continent:
8、First country of each continent:
9、Difficult Questions1:
10、Difficult Questions2:
上面是select子查詢部分所涉及的練習題,題目代碼均能正常運行,獲得預期成功的笑臉結果。后面是對應的測試題代碼,也是能正常運行的代碼,可供大家參考。
二、Nested SELECT Quiz:
Nested SELECT Quiz?sqlzoo.net上面是練習題所涉及的表bbc
1. Select the code that shows the name, region and population of the smallest country in each region:
2.Select the code that shows the countries belonging to regions with all populations over 50000:
3.Select the code that shows the countries with a less than a third of the population of the countries around it:
4.Select the result that would be obtained from the following code:
5.Select the code that would show the countries with a greater GDP than any country in Africa (some countries may have NULL gdp values):
6.Select the code that shows the countries with population smaller than Russia but bigger than Denmark:
7.Select the result that would be obtained from the following code:
子查詢相關知識點:
子查詢就是在一個select查詢語句中嵌套select查詢語句。
一般可以在from子句中直接下定義視圖的sql查詢語句,外面會用一個括號括起來。這是普通的多行子查詢,一般返回多行,也可以返回單行。
也可以結合使用in、any、all在where子句中直接書寫子查詢的sql查詢語句,這種子查詢是標量子查詢。這種子查詢是單一數值,可以結合比較運算符一起使用。
關聯子查詢時要使用兩個表名,第二個表名的ID數據要和第一個表名的ID數據進行匹配。使用關聯條件進行在每個組內比較。
sql里還有5個重要的聚合函數:
count(列名);求某列的行數,如count(*)
sum(列名);對某列數據求和。它只能對數據類型的列計算。
avg(列名);求某列數據的平均值。它只能對數值類型的列計算。
max(列名);求某列數據的最大值
min(列名);求某列數據的最小值
總結
以上是生活随笔為你收集整理的where嵌套select_Select子查询:Select Zoo的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vb仿excel控件_如何通过INTOU
- 下一篇: 集群服务器分布式iis_集群,分布式,微