1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WITH句(SQL)

Last updated at Posted at 2022-12-29

WITH句

  • 副問い合わせ(サブクエリ―)を書くことができる
  • 複数書けるし、使いまわすことができる
  • SQL99の規格に載っている
  • Oracleでは12cから対応

書き方

WITH subqueryname1 as (
  select a,
  count(*) as kensu
  from X
  group by 1
),
subqueryname2 as (
select Y.b,subqueryname1.kensu,
from Y
    join 
    subqueryname1
    on subqueryname1.id=Y.id
)
select subqueryname2.b,Z.c,subqueryname2.kensu
from subqueryname2
join
Z
on Z.id=subqueryname2.id


1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?