I have 2 tables about KPI in PostgreSQL, the first table tab1 contains: “Id”, “Start_Date”, “End_Date” …
and the second table tab2 contains: “Kpi_Id” (fk tab1), “Date” …
In fact, “Start_Date” is for the start of the week and “End_Date” is for the end of the week for a whole year (exp: year =2023, “Start_Date”=’2023-01-01′ and “End_Date”=’2023-01-08′)
So here, I need a function that calls the “Kpi_Id” with “Date” of tab2 between “Start_Date” and “End_Date” of tab1 (exp: “Date”=’2023-01-05′ is between “Start_Date”=’2023-01-01′ and “End_Date”=’2023-01-08′)