Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@NekozeNoMegane

oracle SQL pivot

More than 1 year has passed since last update.

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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?