BigQuery StandardSQL: Time travel last 7 Days using _TABLE_SUFFIX

Problem: To pull and show data that has been inserted only in the last 7 days

\n\n

Solution:

\n\n

Based on the BigQuery Cookbook, that has an example for legacy SQL:

\n\n
#LegacySQL\nSELECT\n  date,\n  SUM (totals.visits) AS visits\nFROM \n  (TABLE_DATE_RANGE([73156703.ga_sessions_], \n  DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY'), \n  DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY')))\nGROUP BY\n  date\nORDER BY\n  date ASC 

dan-irving

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds