Skip to content

Instantly share code, notes, and snippets.

@laurentedel
Last active January 19, 2024 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laurentedel/48826ecd5a5b27d57356b112cb05a3e5 to your computer and use it in GitHub Desktop.
Save laurentedel/48826ecd5a5b27d57356b112cb05a3e5 to your computer and use it in GitHub Desktop.
query to fix
SELECT
i_item_id,
AVG(ss_quantity) AS agg1,
AVG(ss_list_price) AS agg2,
AVG(ss_coupon_amt) AS agg3,
AVG(ss_sales_price AS agg4
FROM
stor_sales
JOIN customer_demographics ON ss_cdemo_sk = cd_demo_sk
JOIN date_dim ON ss_sold_date_sk = d_date_sk
JOIN item ON ss_item_sk = i_item_sk
JOIN promotion ON ss_promo_sk = p_promo_sk
WHERE
cd_gender = 'F'
AND cd_marital_status = 'W'
AND cd_education_status = 'College'
AND (
p_channel_email = 'N'
OR p_channel_event = 'N'
)
AND d_year = 2001
GROUPBY
i_item_id
ORDER BY
i_item_id
LIMITS 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment