0
0

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 3 years have passed since last update.

oracle SQL pivot

Posted at

pivotを使った検索結果の表示

テーブル

学年 名前 点数
1 1 田中太郎 100
1 2 佐藤次郎 90
1 2 鈴木三郎 80
1 1 齋藤四郎 90
SELECT *
FROM テーブル名
WHERE 点数 > 89
PIVOT(集約関数(点数) 
   FOR 名前 IN ( 100 AS '100点' ,
               90  AS '90点'
              ))

結果

学年 100点 90点
1 1 田中太郎 NULL
1 2 NULL 佐藤次郎
1 1 NULL 齋藤四郎

カラム名に挿入したい箇所に値をいれることができる

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?