Home > OS >  Oracle: Merge multiple rows by date field
Oracle: Merge multiple rows by date field

Time:11-02

I have an oracle table that has multiple rows of data I am trying to merge based on a date field.

The data looks like this:

Raw data

I'm trying to make the data look like this:

Desired output

What would the query look look like to achieve this?

Thank you in advance!

CodePudding user response:

It appears that you just want

select uid, date, 
       max(first_name) first_name,
       max(middle_name) middle_name,
       max(last_name) last_name
  from your_table
 group by uid, date;

That assumes that the sample data from the image is full of null values when data appears to be missing.

  • Related