# Week 2 (Nov 23rd - Nov 27th 2020)
## Wednesday Nov 25th
- Do query with selection
```
SELECT DISTINCT column, another_column, …
FROM mytable
WHERE condition(s);
```
- ORDER BY {Column Name} ASC/DESC
- Use LIMIT and OFFSET
```
SELECT column, another_column, …
FROM mytable
WHERE condition(s)
ORDER BY column ASC/DESC
LIMIT num_limit OFFSET num_offset;
```
- Join data for query involved multiple tables
```
SELECT column, another_table_column, …
FROM mytable
INNER JOIN another_table
ON mytable.id = another_table.id
WHERE condition(s)
ORDER BY column, … ASC/DESC
LIMIT num_limit OFFSET num_offset;
```
- Different ways to JOIN
```
SELECT column, another_column, …
FROM mytable
INNER/LEFT/RIGHT/FULL JOIN another_table
ON mytable.id = another_table.matching_id
WHERE condition(s)
ORDER BY column, … ASC/DESC
LIMIT num_limit OFFSET num_offset;
```
- Group by
```
SELECT group_by_column, AGG_FUNC(column_expression) AS aggregate_result_alias, …
FROM mytable
WHERE condition
GROUP BY column
HAVING group_condition;
```
- Subquery
```
SELECT column_names
FROM table_names
WHERE value IN
(SELECT column_names
FROM other_table
WHERE condition)
```
## Thursday Nov 26th
### Morning
### Afternoon