日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

where嵌套select_Select子查询:Select Zoo

發布時間:2023/12/15 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。