sqlzoo練習記錄

2021-10-16 16:50:42 字數 3816 閱讀 1767

簡單的就不寫了,只記錄卡殼的。持更。

如果有誤闖進來的,不要參考我的,沒有參考價值,跪了。

select name

from world

where name like capital

select name

from world

where name = capital

select name

from world

where capital like concat(name,

' city'

)

select capital, name

from world

where capital like concat(

'%', name,

'%')

select name, capital

from world

where capital like concat(name,

'_',

'%')

--寫成concat(name, '_%')就好

參考其他做法

select name,capital from world

where capital like concat(name,

'%')

and capital != name;

select name,

replace

(capital,name,'')

as ext

from world

where capital like concat(name,

'_',

'%')

c (沒啥解釋的眼拙)

我是這麼寫的,也通過了就。

select name,population,area

from world

where

(area >=

3000000

or population >=

250000000

)and name notin(

'united states'

,'india'

,'china'

)

看了其他人的做法,被科普了"xor"

select * from test where a xor b

如果a為真,則查出不滿足b條件資料;

如果a為假,則查出滿足b條件資料;

select name, population, area from world

where area >

3000000

xor population >

250000000

;

select name,

case

when continent=

'caribbean'

then

'north america'

when continent=

'oceania'

then

'australasia'

else continent end

from world

where name like

'n%'

select name,

case

when continent in

('europe'

,'asia'

)then

'eurasia'

when continent in

('north america'

,'south america'

,'caribbean'

)then

'america'

else continent end

from world

where name like

'a%'

or name like

'b%'

put the continents right…

一直做不對是直接除以了題目裡的8000w。阿西。

select name,concat(

round

(population/

(select population from world where name =

'germany')*

100,0)

,'%'

)from world

where continent =

'europe'

隱隱約約懂了,又隱隱約約不懂。

select continent, name, area 

from world x

where area >=

all(

select area from world y

where y.continent=x.continent

and area>

0)

不會做看了別人的答案啊原來這個也可以用大於小於比較啊。

select continent,name from world x

where name <=

all(

select name from world y

where y.continent = x.continent)

;

select continent,name from world

where name in

(select

min(name)

from world

group

by continent)

;

還要好好看看啊

select name,continent,population

from world x

where

25000000

>

all(

select population

from world y

where x.continent = y.continent

group

by continent

)

前幾遍沒有寫y.name != x.name

select name, continent

from world x

where population >=

all(

select population*

3from world y

where x.continent = y.continent

and y.name != x.name )

累了,腦子轉不動了,死刑吧(bushi)

select basics

quiz

select from world 13

quiz

select from nobel

quiz

select in select 有空再寫一遍

quiz

sum and count

quiz

寫完了

sqlzoo練習答案

這個教程介紹sql語言。我們會使用select語句。我們會使用world name continent area population gdp afghanistan asia 652230 25500100 20343000000 albania europe 28748 2831741 1296...

sql 基本查詢 sqlzoo

1.這個例子顯示 france法國 的人口。字串應該在 單引號 中。修改此例子,以顯示德國 germany 的人口。select population from world where name germany 2 查詢顯示面積為 5,000,000 以上平方公里的國家,該國家的人口密度 popul...

SQLzoo刷題 視窗函式

row number select row number over order by 字段 rank select rank over order by 字段 dense rank select dense rank over order by 字段 partition by rank over p...