Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aliases #4382

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ Next, we use the `SELECT` projection to perform some basic renames and data clea

```sql
SELECT
year.Description year_,
area.Description area_,
ethnic.Description ethnic_,
sex.Description sex_,
try_cast(replace(age.Description, ' years', '') AS INTEGER) age_,
try_cast(data.count AS INTEGER) count_
year.Description AS year_,
area.Description AS area_,
ethnic.Description AS ethnic_,
sex.Description AS sex_,
try_cast(replace(age.Description, ' years', '') AS INTEGER) AS age_,
try_cast(data.count AS INTEGER) AS count_
```

The data set contains various totals, so we remove them before proceeding:
Expand All @@ -168,7 +168,7 @@ WHERE count_ > 0
We wrap the previous statements as a common-table-expression `expanded_cleaned_data`, and we can then compute the actual aggregation using DuckDB

```sql
SELECT sex_, sum(count_) group_count
SELECT sex_, sum(count_) AS group_count
FROM expanded_cleaned_data
WHERE age_ BETWEEN 20 AND 40
AND area_ LIKE 'Auckland%'
Expand Down