Skip to content

Commit

Permalink
Merge pull request #4382 from szarnyasg/nits-20241217b
Browse files Browse the repository at this point in the history
Add aliases
  • Loading branch information
szarnyasg authored Dec 17, 2024
2 parents e1b1610 + bcef88a commit 3aacb04
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 3aacb04

Please sign in to comment.