Skip to content
Advertisement

Teradata merge multiple records into single record

I want to merge multiple record into single record Ex: Input

pdt status start_dt end_dt
a Inactive 2022/02/02 2022/02/04
a Inctive 2022/02/05 2022/02/10
a Active 2022/02/10 2022/02/12
b Active 2022/03/13 2022/03/17

Output

pdt status start_dt end_dt
a Active 2022/02/02 2022/02/12
b Active 2022/03/13 2022/03/17

Advertisement

Answer

Normalize the date ranges first, then join back to pick up the most recent status.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement