Exam Certified Data Analyst Associate All QuestionsBrowse all questions from this exam
Question 28

A data analyst is processing a complex aggregation on a table with zero null values and their query returns the following result:

Which of the following queries did the analyst run to obtain the above result?

    Correct Answer: E

    The query used to obtain the provided result uses the CUBE modifier to produce aggregates for all combinations of the values in the group_1 and group_2 columns. This includes the individual groupings, as well as the subtotals and grand total at different hierarchical levels of the grouping chains. The query finds the sum of the values and groups them by all combinations of group_1 and group_2, filling in the subtotal levels with NULL. Thus, the appropriate query would be: SELECT group_1, group_2, SUM(values) AS sum FROM my_table GROUP BY GROUPING SETS ((group_1, group_2), (group_1), (group_2), ()), which is correctly captured by option E.

Discussion
MrWood47Option: E

All the answers provided are incorrect. I don't think it was copied correctly. The correct answer should be below which is closest to option E. SELECT group_1, group_2, SUM(values) AS sum FROM my_table GROUP BY group_1, group_2 WITH CUBE;