Add second year

This commit is contained in:
2023-12-07 01:19:12 +00:00
parent 3291e5c79e
commit 3d12031ab8
1168 changed files with 431409 additions and 0 deletions

View File

@ -0,0 +1,55 @@
- #[[CT230 - Database Systems I]]
- **Previous Topic:** [[SQL SELECT: Working with Strings & Subqueries]]
- **Next Topic:** [[Entity Relationship Models]]
- **Relevant Slides:** ![Topic 6 SQL_DML_aggregateFns and Group By Having.pdf](../assets/Topic_6_SQL_DML_aggregateFns_and_Group_By_Having_1664362673690_0.pdf)
-
- # Aggregate Functions #card
card-last-interval:: 3.58
card-repeats:: 1
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-03T21:34:29.060Z
card-last-reviewed:: 2022-09-30T08:34:29.061Z
card-last-score:: 3
- **Aggregate Functions** are only supported in `SELECT` clauses & `HAVING` clauses.
- Keywords `SUM`, `AVG`, `MIN`, `MAX` work as expected and can only be applied to **numeric** data.
- Keyword `COUNT` can be used to count the number of tuples / values / rows specified in a query.
- We can also use mathematical operations as part of an aggregate function on **numeric** data, e.g., `+`, `-`, `*`, `/`.
- # `GROUP BY` #card
card-last-interval:: 3.58
card-repeats:: 1
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-03T21:36:41.416Z
card-last-reviewed:: 2022-09-30T08:36:41.416Z
card-last-score:: 3
- `GROUP BY <group attributes>`
- The `GROUP BY` clause allows the grouping of rows of a table together so that all occurrences within a specified group are collected together.
- Aggregate clauses can then be applied to groups.
- ## Using Aggregate Functions with `GROUP BY` #card
card-last-interval:: -1
card-repeats:: 1
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-06T23:00:00.000Z
card-last-reviewed:: 2022-10-06T09:42:27.555Z
card-last-score:: 1
- The `GROUP BY` clause specifies the group and the aggregate function is applied to the group.
- `COUNT(*)` can be used to *count* the number of rows (tuples) in the specified groups.
- `SUM`, `AVG`, `MIN`, `MAX` can be used to find the sum, average, min, & max of a *numerical value* in a specified group.
- ^^**Important:** You must `GROUP BY` **all** attributes in the `SELECT` clause *unless* they are involved in an aggregation.^^
- This **^^wouldn't work^^** as we do not `GROUP BY` all the attributes in the `SELECT` clause - `salary` remains ungrouped.
- ```SQL
SELECT dno, salary
FROM employee
GROUP BY dno -- THIS IS WRONG
```
-
- # `HAVING` #card
card-last-interval:: -1
card-repeats:: 1
card-ease-factor:: 2.5
card-next-schedule:: 2022-09-30T23:00:00.000Z
card-last-reviewed:: 2022-09-30T08:32:55.188Z
card-last-score:: 1
- `HAVING <group condition>`
- The `HAVING` clause is used in conjunction with `GROUP BY` and allows the specification of **conditions on groups**.
- The column names in the `HAVING` clause must also appear in the `GROUP BY` list or be contained within an aggregate function, i.e., you cannot apply a `HAVING` condition to something that has not been calculated already.
-

View File

@ -0,0 +1,55 @@
- #[[CT230 - Database Systems I]]
- **Previous Topic:** [[SQL SELECT: Working with Strings & Subqueries]]
- **Next Topic:** [[Entity Relationship Models]]
- **Relevant Slides:** ![Topic 6 SQL_DML_aggregateFns and Group By Having.pdf](../assets/Topic_6_SQL_DML_aggregateFns_and_Group_By_Having_1664362673690_0.pdf)
-
- # Aggregate Functions #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.46
card-next-schedule:: 2022-10-11T03:37:18.526Z
card-last-reviewed:: 2022-10-07T10:37:18.527Z
card-last-score:: 5
- **Aggregate Functions** are only supported in `SELECT` clauses & `HAVING` clauses.
- Keywords `SUM`, `AVG`, `MIN`, `MAX` work as expected and can only be applied to **numeric** data.
- Keyword `COUNT` can be used to count the number of tuples / values / rows specified in a query.
- We can also use mathematical operations as part of an aggregate function on **numeric** data, e.g., `+`, `-`, `*`, `/`.
- # `GROUP BY` #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.46
card-next-schedule:: 2022-10-11T03:37:37.905Z
card-last-reviewed:: 2022-10-07T10:37:37.905Z
card-last-score:: 5
- `GROUP BY <group attributes>`
- The `GROUP BY` clause allows the grouping of rows of a table together so that all occurrences within a specified group are collected together.
- Aggregate clauses can then be applied to groups.
- ## Using Aggregate Functions with `GROUP BY` #card
card-last-interval:: -1
card-repeats:: 1
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-08T23:00:00.000Z
card-last-reviewed:: 2022-10-08T15:01:12.709Z
card-last-score:: 1
- The `GROUP BY` clause specifies the group and the aggregate function is applied to the group.
- `COUNT(*)` can be used to *count* the number of rows (tuples) in the specified groups.
- `SUM`, `AVG`, `MIN`, `MAX` can be used to find the sum, average, min, & max of a *numerical value* in a specified group.
- ^^**Important:** You must `GROUP BY` **all** attributes in the `SELECT` clause *unless* they are involved in an aggregation.^^
- This **^^wouldn't work^^** as we do not `GROUP BY` all the attributes in the `SELECT` clause - `salary` remains ungrouped.
- ```SQL
SELECT dno, salary
FROM employee
GROUP BY dno -- THIS IS WRONG
```
-
- # `HAVING` #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-10T10:16:13.976Z
card-last-reviewed:: 2022-10-06T17:16:13.977Z
card-last-score:: 3
- `HAVING <group condition>`
- The `HAVING` clause is used in conjunction with `GROUP BY` and allows the specification of **conditions on groups**.
- The column names in the `HAVING` clause must also appear in the `GROUP BY` list or be contained within an aggregate function, i.e., you cannot apply a `HAVING` condition to something that has not been calculated already.
-

View File

@ -0,0 +1,55 @@
- #[[CT230 - Database Systems I]]
- **Previous Topic:** [[SQL SELECT: Working with Strings & Subqueries]]
- **Next Topic:** [[Entity Relationship Models]]
- **Relevant Slides:** ![Topic 6 SQL_DML_aggregateFns and Group By Having.pdf](../assets/Topic_6_SQL_DML_aggregateFns_and_Group_By_Having_1664362673690_0.pdf)
-
- # Aggregate Functions #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.46
card-next-schedule:: 2022-10-11T03:37:18.526Z
card-last-reviewed:: 2022-10-07T10:37:18.527Z
card-last-score:: 5
- **Aggregate Functions** are only supported in `SELECT` clauses & `HAVING` clauses.
- Keywords `SUM`, `AVG`, `MIN`, `MAX` work as expected and can only be applied to **numeric** data.
- Keyword `COUNT` can be used to count the number of tuples / values / rows specified in a query.
- We can also use mathematical operations as part of an aggregate function on **numeric** data, e.g., `+`, `-`, `*`, `/`.
- # `GROUP BY` #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.46
card-next-schedule:: 2022-10-11T03:37:37.905Z
card-last-reviewed:: 2022-10-07T10:37:37.905Z
card-last-score:: 5
- `GROUP BY <group attributes>`
- The `GROUP BY` clause allows the grouping of rows of a table together so that all occurrences within a specified group are collected together.
- Aggregate clauses can then be applied to groups.
- ## Using Aggregate Functions with `GROUP BY` #card
card-last-interval:: 3.45
card-repeats:: 2
card-ease-factor:: 2.46
card-next-schedule:: 2022-10-13T21:32:53.059Z
card-last-reviewed:: 2022-10-10T11:32:53.059Z
card-last-score:: 5
- The `GROUP BY` clause specifies the group and the aggregate function is applied to the group.
- `COUNT(*)` can be used to *count* the number of rows (tuples) in the specified groups.
- `SUM`, `AVG`, `MIN`, `MAX` can be used to find the sum, average, min, & max of a *numerical value* in a specified group.
- ^^**Important:** You must `GROUP BY` **all** attributes in the `SELECT` clause *unless* they are involved in an aggregation.^^
- This **^^wouldn't work^^** as we do not `GROUP BY` all the attributes in the `SELECT` clause - `salary` remains ungrouped.
- ```SQL
SELECT dno, salary
FROM employee
GROUP BY dno -- THIS IS WRONG
```
-
- # `HAVING` #card
card-last-interval:: 3.71
card-repeats:: 2
card-ease-factor:: 2.36
card-next-schedule:: 2022-10-10T10:16:13.976Z
card-last-reviewed:: 2022-10-06T17:16:13.977Z
card-last-score:: 3
- `HAVING <group condition>`
- The `HAVING` clause is used in conjunction with `GROUP BY` and allows the specification of **conditions on groups**.
- The column names in the `HAVING` clause must also appear in the `GROUP BY` list or be contained within an aggregate function, i.e., you cannot apply a `HAVING` condition to something that has not been calculated already.
-