0

I'm just going to ask how to query combine datas with same column and ignore all null values

actual table:

 id |   first_name  |   last name  |    age   |   unique_id 
  1 |      Doe      |              |          |         111
  2 |               |     John     |          |         111
  3 |               |              |     32   |         111
  4 |      Reeves   |              |          |         222
  5 |               |      Keanu   |          |         222

wanted query result :

      first_name  |   last name  |    age   |   unique_id 
          Doe     |     John     |     32   |      111
          Keanu   |     Reeves   |          |      222
  

Thanks!!

0

1 Answer 1

2

Aggregate by unique_id and use MAX:

SELECT
    unique_id,
    MAX(first_name) AS first_name,
    MAX(last_name) AS last_name,
    MAX(age) AS age
FROM yourTable
GROUP BY
    unique_id;
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome!!! Thanks bud!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.