Skip to content

Commit

Permalink
Update cte.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
kdyl committed Feb 11, 2022
1 parent 992570b commit f7b369a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cte.sql
Expand Up @@ -5,12 +5,14 @@ WITH all_products AS ( -- count all products per transaction
FROM transactions
GROUP BY transaction_id, month
)
, electronic_products AS ( -- count phones and computers per transaction
, electronic_products AS ( -- count phones, computers and monitors per transaction
SELECT t.transaction_id
, count(t.product_id) AS count_electronic_products
FROM transactions t
JOIN category c ON t.category_id = c.category_id
WHERE c.category_name = 'PHONE' or c.category_name = 'COMPUTER'
WHERE c.category_name = 'PHONE'
OR c.category_name = 'COMPUTER'
OR c.category_name = 'MONITOR'
GROUP BY t.transaction_id
)
, ratio_electronic_to_all AS ( -- calculate ratio of electronic to all products per transaction
Expand Down

0 comments on commit f7b369a

Please sign in to comment.