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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

sql select 基础用法

發(fā)布時間:2023/12/8 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sql select 基础用法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1 數(shù)據(jù)集介紹


在線運行:

https://sqlzoo.net/wiki/SELECT_basics

2 練習題

2.1 知識儲備

  • 字符串需要使用單引號
  • 使用in可以檢查某一項是否位于某個列表內(nèi)
  • 使用between XXX and XXX可以檢查某一項是否位于某個范圍內(nèi)

2.2 練習

show the population of Germany
select population from world where name = 'Germany';
Show the name and the population for ‘Sweden’, ‘Norway’ and ‘Denmark’.
select name,population from world where name in ('Sweden','Norway','Denmark');
show the country and the area for countries with an area between 200,000 and 250,000
select name,area from world where area between 200000 and 250000;

3 十三道和world表關聯(lián)的sql語句

https://sqlzoo.net/wiki/SELECT_from_WORLD_Tutorial

1

SELECT name, continent, population FROM world

2

select name from world where population > 200000000;

3

select name, gdp/population from world where population > 200000000;

4

select name,population/1000000 from world where continent = 'South America';

5

select name,population from world where name in ('France','Germany','Italy');

6

select name from world where name like '%United%';

7

select name,population,area from world where area > 3000000 or population > 250000000;

8

select name,population,area from world where area > 3000000 and population < 250000000 or area < 3000000 and population > 250000000;

9

select name,round(population/1000000,2),round(gdp/1000000000,2) from world where continent = 'South America';

10

select name,round(gdp/population,-3) from world where gdp > 1000000000000;

11

SELECT name,capital FROM world WHERE LEN(name)=LEN(capital)

12

select name,capital from world where left(name,1) = left (capital,1) and name <> capital;

13

select name from world where name like '%a%' and name like '%e%' and name like '%i%' and name like '%o%' and name like '%u%' and name not like '% %';

4 十四道和nobel表關聯(lián)的sql語句

https://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

1

select * from nobel where yr=1950;

2

SELECT winnerFROM nobelWHERE yr = 1962AND subject = 'literature'

3

select yr,subject from nobel where winner='Albert Einstein'

4

select winner from nobel where yr >= 2000 and subject = 'peace';

5

select * from nobel where yr between 1980 and 1989 and subject = 'literature'

6

select * from nobel where winner in ('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter','Barack Obama');

7

select winner from nobel where winner like 'John%';

8

select yr,subject,winner from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry')

9

select yr,subject,winner from nobel where yr=1980 and subject not in ('chemistry');

10

select yr,subject,winner from nobel where (subject='Medicine' and yr < 1910) or (subject='Literature' and yr>=2004)

11

select * from nobel where winner = 'PETER GRüNBERG'

12

select * from nobel where winner = 'EUGENE O''NEILL'

13

select winner,yr,subject from nobel where winner like 'Sir%' order by yr desc,winner asc;

14

應該是正確答案,但是不對,不知道為啥:

SELECT winner, subject FROM nobel WHERE yr=1984 ORDER BY subject IN ('Physics','Chemistry'),subject,winner

總結(jié)

以上是生活随笔為你收集整理的sql select 基础用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。