S
S
SergeySafaryanc2020-02-27 14:32:29
SQL
SergeySafaryanc, 2020-02-27 14:32:29

How to merge records with same columns by expanding time range??

How to merge records with same columns by expanding time range??
Table example.
| id | date_from | date_to | param1 | param2 |
|
_
_
_
_

_
_ id | date_from | date_to | param1 | param2 |
1 2009 2012 'A' 'A'
1 2013 2014 'B' 'B' 1 2015 2018
'A' 'A'

dense_rank() over(partition by id order by param1, param2) as rnk,
*
from
Table

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-02-27
@freeExec

Wouldn't it work with normal grouping?

SELECT id, MIN(date_from), MAX(data_to), para1, param2 FROM table GROUP BY id, param1, param2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question