Gaurav Tiwari
03/29/2023, 10:33 AMJan Soubusta
03/29/2023, 10:36 AMGaurav Tiwari
03/29/2023, 10:44 AMJan Soubusta
03/29/2023, 11:09 AMJan Soubusta
03/29/2023, 11:11 AMJan Soubusta
03/29/2023, 11:11 AMGaurav Tiwari
03/29/2023, 2:20 PMGaurav Tiwari
03/30/2023, 10:26 AMGaurav Tiwari
03/30/2023, 12:19 PMJan Soubusta
03/30/2023, 1:42 PMJan Soubusta
03/30/2023, 1:53 PMSELECT
SUM(UCD.duration)/ 3600 AS hrs,
UCA.course_assignment_name
FROM
user_course_assignments AS UCA
LEFT OUTER JOIN user_course_durations AS UCD
ON UCD.user_course_id = UCA.course_id
GROUP BY
UCA.course_assignment_name
;
In this case, I want to select all course assignments (their names) and their SUM(duration), if a corresponding record in user_course_durations
exists, otherwise NULL.
Additionally, you could use COALESCE function and define default when NULL, e.g. 0.
This would be managed in MAQL like this:
SELECT SUM({fact/duration}) FOR EACH {label/course_assignment_name}
Or more general solution is to specify the whole dataset after FOR EACH:
SELECT SUM({fact/duration}) FOR EACH {dataset/course_assignments}
Then, when you put such a metric to a visualization and add any attribute/label from user_course_assignments
, we generate OUTER JOIN under-the-hood.