Sources
- SQL Joints (Lecture Slides)
- SQL Aggregation (Lecture Slides)
Joints
Joins combine rows from different tables through related columns. They allow for the retrieval and presentation of related data.
NOTE
Types of Joints
- Inner Join: Only returns rows with matching values.
- Left (Outer) Join: Returns all rows from the left table and the matching rows from the right table. If no matches, NULL in the right table.
- Right (Outer) Join: Returns all rows from the right table and the matching rows from the left table. If no matches, NULL in the left table.
- Full (Outer) Join: Returns all rows from both table. Returns NULL in either when one is not matching with any.
- Cross Join: Returns the combinations of all rows in both tables.
Aggregation
Aggregate functions perform calculations on a set of values and generates a result.
NOTE
Types of Aggregation
- COUNT(): Counts the number of rows.
- SUM(): Provides the sum of a numeric column.
- AVG(): Provides the average of a numeric column.
- MIN(): Finds the minimum in a column.
- MAX(): Finds the maximum in a column.
- GROUP BY(): Groups rows with the same values in a specified column.