I have a lot of data with a lot of dates (date begin, date end, date activation etc.). I would like to retrieve those data selecting a specific time range and returning a period date.
I want only results where:
(last month date) <= Date Activation and (last month date) > Date End
+ return the column containing the period
If I select a unique period:
select "client Name","Program" from "database"."schema"."table"
WHERE "Date Activation" <= '2020-12-31' AND "Date End" > '2020-12-31'
The aim is to retrieve results like this (I want it for all periods in my table):
client Name | Program | period |
---|---|---|
client 1 | program 1 | 2020/11/30 |
client 2 | program 2 | 2020/12/31 |
client 3 | program 3 | 2020/12/31 |
client 3 | program 3 | 2021/01/31 |
client 1 | program 1 | 2021/01/31 |
client 2 | program 4 | 2021/02/28 |