×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Gial Ackbar
Added: Mar 31, 2017 8:12 PM
Views: 8
Tags: no tags
  1. ##### Backfill query to be run on db-top100 database
  2. select
  3.   ? as client_id,
  4.   ## make it subtract 6 days for week beginning 2016-10-02
  5.   u.DataSet_Date - interval dayofweek(u.DataSet_Date) - 1 day as week_beginning,
  6.   u.asin,
  7.   u.units,
  8.   s.sales,
  9.   round(s.sales / u.units, 2) as asp
  10. FROM top100s_units as u
  11. Join top100s_sales as s on (u.Dataset_Date = s.Dataset_Date and u.asin = s.asin)
  12. where u.Dataset_Date = ?
  13. and u.asin in (
  14.   ###INSERT ASINS HERE
  15. );