I am using Vertica Enterprise for my warehouse.
I have three tables.
Table #1 - Students
Table #2 - Address of Students
Table #3 - Homework progress of Students done for the day. (Note: some of students might be absent on that day). Homework progress column is in %.
Desired output
I want all the days that exists in table 3 and all the students from table 1 along with their addresses from table 2 in a single table.
Here is my attempt but I have to run the query for each day. Meaning I have to keep changing HOMEWORK.day = '2023-11-01' and TO_DATE(TO_CHAR(20231101), 'YYYY-MM-DD') AS DAY_ for each run.
INSERT INTO TABLE_4
SELECT
TO_DATE(TO_CHAR(20231101),'YYYY-MM-DD') AS DAY_,
A.ID AS ID,
A.NAME AS NAME,
B.ADDRESS AS ADDRESS,
NVL(C.HOMEWORK_PROGRESS,0.0) AS PROGRESS
FROM
STUDENTS AS STUDENT
INNER JOIN
ADDRESS AS ADDRESS ON STUDENT.ID = ADDRESS.ID
LEFT JOIN
HOMEWORK AS HOMEWORK ON STUDENT.ID = HOMEWORK.ID AND HOMEWORK.DAY = '2023-11-01'
I want to rewrite it so that I can just do HOMEWORK.DAY BETWEEN '2023-11-01' AND '2023-11-30' and let it run by itself.




did you try the obvious one :
?