Skip to content
Advertisement

SQL – Aggregates data with dates interval

i’m facing a problem joining two table with date interval that represent user status change. ID is the same in both table.

Table_A

Table_B

What i’m trying to obtain is a table like that:

The query i wrote at the very beginning:

Thanks in advance!

EDIT: each ID uniquely identifies a user. So, user with ID = 1 in Table_A is the same user with ID = 1 in Table_B

EDIT_02: Thanks to Gordon Linoff solution, i have now

This query is working, but i could have the situation that

Advertisement

Answer

You seem to just want a join with the right conditions on the time columns:

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