『スッキリわかるSQL入門 第2版』のドリルを解き、ひたすら答えを載せていくシリーズです。今回は題材A・LEVEL3。最後の33でつまずきました。
24.
select *
from 口座
order by 口座番号
25.
select distinct 名義
from 口座
order by 名義
26.
select *
from 口座
order by 残高 desc, 口座番号
27.
select 更新日
from 口座
where 更新日 is not null
order by 更新日
offset 0 rows
fetch next 10 rows only
28.
select 更新日,残高
from 口座
where 残高 <> 0
and 更新日 is not null
order by 残高, 更新日 desc
offset 10 rows
fetch next 10 rows only
29.
select 口座番号
from 口座
union
select 口座番号
from 廃止口座
order by 口座番号
30.
select 名義
from 口座
except
select 名義
from 廃止口座
order by 名義 desc
31.
select 名義
from 口座
intersect
select 名義
from 廃止口座
32.
select 口座番号, 残高
from 口座
where 残高 = 0
union
select 口座番号, 解約時残高
from 廃止口座
where 解約時残高 <> 0
order by 1
33.
select 口座番号,名義,'❍' as 区分
from 口座
union
select 口座番号,名義, '✕' as 区分
from 廃止口座
order by 名義