hii how can we perform inner join in good data mat...
# gooddata-platform
g
hii how can we perform inner join in good data matrices
j
INNER JOIN is the default behavior.
g
and for left and right
j
I know only about GoodData.CN / GoodData cloud - there OUTER JOIN can be triggered by using "Show missing values" in our UI apps or by FOR EACH clause in our MAQL language.
It works not only for DATE attributes but for all attributes
g
supose my sql query is Select SUM(UCD.duration)/3600 as hrs from user_course_assignments AS UCA LEFT OUTER JOIN user_course_durations AS UCD ON UCD.user_course_id = UCA.course_id than what will maql query
hii please reply
@Jan Soubusta please reply
j
sorry, was focused on the yesterday meetup and today was full of meetings.
There is no GROUP BY in your query. In the SELECT section you use only UCD.duration. The LEFT OUTER JOIN does not change anything here. If you would SELECT SUM() without JOIN, the result would be the same. Here is the query where the OUTER JOIN plays active role:
Copy code
SELECT
	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:
Copy code
SELECT SUM({fact/duration}) FOR EACH {label/course_assignment_name}
Or more general solution is to specify the whole dataset after FOR EACH:
Copy code
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.