课程: Intermediate SQL for Data Scientists
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Using ROLLUP to create subtotals
- [Instructor] When we work with aggregates, we can use the aggregates, say, to get the totals, maybe the average or some sums or some counts across an entire table. Or we have seen, we can also use the group by expression or the group by clause in the select statement to apply those aggregates to subgroups within, say, a table. So for example, we could maybe group by a department name to see the count of the number of employees within each department. Well, SQL and Postgres actually has another operator we can use called roll up, which gives us a third way of working with aggregates. And roll up allows us to do sort of like sub aggregates in a hierarchical fashion. So for example, in our data model, we have company regions, and these regions are part of countries. So we could, for example, with roll up, get our total number of employees by region and then also get a total count by country and then also a total count by the whole table of employees. So that's what the roll up operator…
内容
-
-
-
-
-
-
Using the HAVING clause to find subgroups7 分钟 28 秒
-
(已锁定)
Subqueries for column values7 分钟 43 秒
-
(已锁定)
Subqueries in FROM clauses2 分钟 57 秒
-
(已锁定)
Subqueries in WHERE clauses2 分钟 42 秒
-
(已锁定)
Using ROLLUP to create subtotals7 分钟 27 秒
-
(已锁定)
Using CUBE to total across dimensions10 分钟 40 秒
-
(已锁定)
Using Top-N queries to find top results3 分钟 18 秒
-
(已锁定)
Challenge: Filter and aggregate a data set21 秒
-
(已锁定)
Solution: Filter and aggregate a data set52 秒
-
-
-
-
-
-