Skip to content

Instantly share code, notes, and snippets.

@haydarai
Created December 8, 2018 17:52
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 haydarai/40b4289b9a0d0c7d63efd298cd44381a to your computer and use it in GitHub Desktop.
Save haydarai/40b4289b9a0d0c7d63efd298cd44381a to your computer and use it in GitHub Desktop.
Store Returns
select date_dim.d_year, item.i_item_sk, reason.r_reason_sk, sum(sr_return_quantity) as quantity
from store_returns, date_dim, item, reason
where store_returns.sr_returned_date_sk = date_dim.d_date_sk
and store_returns.sr_item_sk = item.i_item_sk
and store_returns.sr_reason_sk = reason.r_reason_sk
group by cube(date_dim.d_year, sr_item_sk, r_reason_sk)
order by date_dim.d_year, reason.r_reason.sk, item.i_item_sk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment