google bigquery - Problems with translating MYSQL query using date_add function and time intervals for BQ -


i have query runs on our mysql database. takes forever run, use bigquery instead. relevant table (a.xxx) in cloud, , i've tried adjusting code bq, i'm not having luck. query pulls number of individuals making purchases day, , number of same individuals, made purchase 1-7 days after initial purchase. appreciate help!!!!

here query:

    select f.fts_date,  count(distinct f.fts_id) fts_count,  count(distinct s.passportid) svs_count,  (count(distinct s.passportid)/count(distinct f.fts_id)) return_rate    (select passportid fts_id,addressid, date(signdatetime) fts_date a.xxx  date(signdatetime)>'2015-6-10'  , fts="y" , disposition="accepted") f  left join a.xxx s on f.passportid=s.passportid , f.addressid=s.addressid , s.disposition="accepted" ,  s.signdatetime between date_add(f.signdatetime, 1, "day") , date_add(f.signdatetime, 7, "day")    group 1 

bigquery doesn't support interval keyword in date_add function, instead should write

date_add(fts_date, 1, "day") 

see https://cloud.google.com/bigquery/query-reference#datetimefunctions more details


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -