Skip to content

Commit 0486acc

Browse files
authored
Files for the issue #SQL-348 (#251)
* Create grouping_data.sql * Add files for the tutorial SUM_groupby_id * Rename complex_aggregation_example.sql to complex-aggregation-example.sql * Rename filter_group_result.sql to filter-group-result.sql * Rename grouping_data.sql to grouping-data.sql * Rename handling_null_values.sql to handling-null-values.sql * Rename the folder name for the issue * Delete .vscode directory
1 parent 1bf9ccb commit 0486acc

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT s.id, s.name, SUM(c.credits) AS student_credits
2+
FROM Student s
3+
LEFT JOIN Registration r ON s.id = r.student_id
4+
LEFT JOIN Course c ON r.course_id = c.id
5+
GROUP BY s.id, s.name;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT department_id, SUM(credits) AS dept_total_credits
2+
FROM Course
3+
GROUP BY department_id
4+
HAVING SUM(credits) > 80;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT department_id, SUM(credits) AS dept_total_credits
2+
FROM Course
3+
GROUP BY department_id;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT s.id, s.name, SUM(COALESCE(c.credits, 0)) AS student_credits
2+
FROM Student s
3+
LEFT JOIN Registration r ON s.id = r.student_id
4+
LEFT JOIN Course c ON r.course_id = c.id
5+
GROUP BY s.id, s.name;

0 commit comments

Comments
 (0)