Skip to content

Instantly share code, notes, and snippets.

@haydarai
Created December 8, 2018 18:01
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/f38e8c1c0f85afe9ab0f69e2d953eb72 to your computer and use it in GitHub Desktop.
Save haydarai/f38e8c1c0f85afe9ab0f69e2d953eb72 to your computer and use it in GitHub Desktop.
Catalog returns
select date_dim.d_year, item.i_item_sk, reason.r_reason_sk, sum(catalog_returns.cr_return_quantity) as quantity
from catalog_returns, date_dim, item, reason
where catalog_returns.cr_returned_date_sk = date_dim.d_date_sk
and catalog_returns.cr_item_sk = item.i_item_sk
and catalog_returns.cr_reason_sk = reason.r_reason_sk
group by cube(date_dim.d_year, item.i_item_sk, reason.r_reason_sk)
order by date_dim.d_year, item.i_item_sk, reason.r_reason_sk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment