Skip to content

Commit

Permalink
Minor comment tweak about aggr()
Browse files Browse the repository at this point in the history
  • Loading branch information
hlapp committed Nov 7, 2023
1 parent 5faeaa0 commit fe64703
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lesson-04.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ GROUP BY i.Name, c.Name, c.Semester;
- If neither, the value is from a randomly chosen member of the group.
```{sql, label=selectG1.1}
SELECT i.Name AS Instructor, c.Name AS Course,
MAX(c.Semester) AS Semester, -- values are the same in a group; AGGR() ensures it's non-NULL
MAX(c.Semester) AS LastSemester, -- choose one non-NULL value from group
COUNT(l.Name) AS '#Lessons'
FROM Lesson AS l INNER JOIN Course AS c USING (Course_OID)
RIGHT OUTER JOIN Instructor AS i USING (Instructor_OID)
Expand Down
4 changes: 2 additions & 2 deletions pub/Lesson-04.html
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ <h2>Grouping vs aggregating</h2>
</ul>
<div class="cell">
<div class="sourceCode cell-code" id="cb46"><pre class="sourceCode numberSource sql number-lines code-with-copy"><code class="sourceCode sql"><span id="cb46-1"><a href="#cb46-1"></a><span class="kw">SELECT</span> i.Name <span class="kw">AS</span> Instructor, c.Name <span class="kw">AS</span> Course,</span>
<span id="cb46-2"><a href="#cb46-2"></a> <span class="fu">MAX</span>(c.Semester) <span class="kw">AS</span> Semester, <span class="co">-- values are the same in a group; AGGR() ensures it's non-NULL</span></span>
<span id="cb46-2"><a href="#cb46-2"></a> <span class="fu">MAX</span>(c.Semester) <span class="kw">AS</span> LastSemester, <span class="co">-- choose one non-NULL value from group</span></span>
<span id="cb46-3"><a href="#cb46-3"></a> <span class="fu">COUNT</span>(l.Name) <span class="kw">AS</span> <span class="st">'#Lessons'</span></span>
<span id="cb46-4"><a href="#cb46-4"></a><span class="kw">FROM</span> Lesson <span class="kw">AS</span> l <span class="kw">INNER</span> <span class="kw">JOIN</span> Course <span class="kw">AS</span> c <span class="kw">USING</span> (Course_OID)</span>
<span id="cb46-5"><a href="#cb46-5"></a> <span class="kw">RIGHT</span> <span class="kw">OUTER</span> <span class="kw">JOIN</span> Instructor <span class="kw">AS</span> i <span class="kw">USING</span> (Instructor_OID)</span>
Expand All @@ -1503,7 +1503,7 @@ <h2>Grouping vs aggregating</h2>
<tr class="header">
<th style="text-align: left;">Instructor</th>
<th style="text-align: left;">Course</th>
<th style="text-align: left;">Semester</th>
<th style="text-align: left;">LastSemester</th>
<th style="text-align: right;">#Lessons</th>
</tr>
</thead>
Expand Down

0 comments on commit fe64703

Please sign in to comment.