地層を剥がす

声を失った人間の発声練習です

『スッキリわかるSQL入門 第2版』ドリル(題材A・LEVEL6)の答え

『スッキリわかるSQL入門 第2版』のドリルを解き、ひたすら答えを載せていくシリーズです。今回は題材A・LEVEL6。手強かったです。

 

59.

update 口座
set 残高 =(select (sum(入金額)-sum(出金額)) as 残高
from 取引
where 口座番号 = '0351333'
and 日付 = '2018-01-11'), 更新日 = '2018-01-11'
where 口座番号 = '0351333'

 

60.

 select 残高, (select sum(入金額) from 取引select 残高, (select sum(入金額) from 取引    where 口座番号 = '1115600' and 日付 = '2017-12-28') as 入金額, (select sum(出金額) from 取引    where 口座番号 = '1115600' and 日付 = '2017-12-28') as 出金額from 口座where 口座番号 = '1115600'

 

61.

select 口座番号, 名義, 残高 select 口座番号, 名義, 残高 from 口座 where 口座番号 in (select 口座番号 from 取引   where 入金額 >= 1000000)

 

62.

select *
from 口座
where 更新日 > all(select 日付 from 取引)

 

63.

自力では解けなかったため割愛

 

64.

 insert into 廃止口座
(select * from 口座 where 口座番号 = '2761055');
delete from 口座
where 口座番号 = '2761055';