Skip to content

Instantly share code, notes, and snippets.

@kokosing
Created March 29, 2016 07:31
Show Gist options
  • Save kokosing/7e65102cfc8bd8724491 to your computer and use it in GitHub Desktop.
Save kokosing/7e65102cfc8bd8724491 to your computer and use it in GitHub Desktop.
*** q21.sql 2016-03-25 14:10:21.906553746 +0100
--- q21_modified.sql 2016-03-25 14:10:21.906553746 +0100
***************
*** 10,20 ****
 "${database}"."${schema}".date_dim
 WHERE i_current_price BETWEEN 0.99 AND 1.49
 AND i_item_sk = inv_item_sk
 AND inv_warehouse_sk = w_warehouse_sk
 AND inv_date_sk = d_date_sk
! AND d_date BETWEEN (CAST ('1999-06-23' AS date) - 30 days) AND (CAST ('1999-06-23' AS date) + 30 days)
 GROUP BY w_warehouse_name,
 i_item_id) x
 WHERE (CASE WHEN inv_before > 0 THEN inv_after / inv_before ELSE NULL END) BETWEEN 2.0/3.0 AND 3.0/2.0
 ORDER BY w_warehouse_name,
 i_item_id LIMIT 100;
--- 10,20 ----
 "${database}"."${schema}".date_dim
 WHERE i_current_price BETWEEN 0.99 AND 1.49
 AND i_item_sk = inv_item_sk
 AND inv_warehouse_sk = w_warehouse_sk
 AND inv_date_sk = d_date_sk
! AND d_date BETWEEN (CAST ('1999-06-23' AS date) - INTERVAL '30' DAY) AND (CAST ('1999-06-23' AS date) + INTERVAL '30' DAY)
 GROUP BY w_warehouse_name,
 i_item_id) x
 WHERE (CASE WHEN inv_before > 0 THEN inv_after / inv_before ELSE NULL END) BETWEEN 2.0/3.0 AND 3.0/2.0
 ORDER BY w_warehouse_name,
 i_item_id LIMIT 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment