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?

SQLの行集約方法【PostgreSQL】

Posted at

説明

  1. MAX 関数を利用して複数の行を1つに集約し、値がある場合はその値を、値がない場合は NULL を設定します。
  2. MAX は NULL 値を無視し、値が存在する場合にはその値を取得します。
-- SQL
SELECT
    MAX(column1) AS column1
    , MAX(column2) AS column2
    , MAX(column3) AS column3
FROM
    my_table;

元データ

column1 column2 column3
null TEST2 null
TEST1 null TEST3

実行結果

column1 column2 column3
TEST1 TEST2 TEST3
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?