Skip to content

Commit ba8bf69

Browse files
committed
DataCamp - Submit "Data manipulation in Snowflake" - 2 - Where are customers buying?
1 parent 8f59ff6 commit ba8bf69

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

datacamp/data_manipulation_in_snowflake.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,21 @@ ORDER BY cost_per_second DESC;
226226
```
227227

228228
## Where are customers buying?
229-
```
229+
```sql
230+
WITH usa_invoices AS (
231+
SELECT
232+
invoice_id,
233+
billing_state
234+
FROM invoice
235+
WHERE billing_country = 'USA'
236+
)
230237

238+
SELECT
239+
COUNT(quantity)
240+
FROM usa_invoices
241+
JOIN invoiceline
242+
GROUP BY billing_state
243+
ORDER BY COUNT(quantity) DESC;
231244
```
232245

233246
## Advanced Common Table Expressions

0 commit comments

Comments
 (0)