Last active
March 1, 2023 06:01
-
-
Save sh16ma/39899cdb4cff7a91ce3be7d11cd524cf to your computer and use it in GitHub Desktop.
#π #BigQuery #BigQueryScripting #_TABLE_SUFFIX #ga_data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#standaardSQL | |
# ιθ¨ζι | |
decleare term_start string default '2020-01-01'; | |
decleare term_end string default '2020-12-31'; | |
decleare prep_table_suffix string; | |
set prep_table_suffix = ( | |
select format_date('%Y%m%d', current_date('Asia/Tokyo')) as TODAY | |
); | |
with | |
rsv_raw as ( | |
select * from `pj.ds.hoge_reservation_*` where _TABLE_SUFFIX = prep_table_suffix | |
) | |
,rsv_prep as ( | |
# εε¦ηγγΌγγ« | |
select | |
SHOPOWNER_ID | |
, RSV_DATE | |
, date_trunc(RSV_DATE, day) as RSV_DATE_TRUNC | |
, APPOINT_DATETIME | |
, RSV_VALID | |
, LOG_NO | |
, MENU_ID | |
from | |
rsv_raw | |
where | |
RSV_VALID = '1' --ζεΉδΊη΄ | |
) | |
, info_raw as ( | |
select 1 | |
) | |
, info_prep as ( | |
select 1 | |
) | |
, ga_raw as ( | |
select 1 | |
) | |
, ga_prep as ( | |
select 1 | |
) | |
, output as ( | |
select | |
MENU-ID | |
, count(distinct LOG_NO) as CV | |
from | |
rsv_prep | |
where | |
RSV_DATE_TRUNC between datetime(term_start) and datetime(term_end) | |
) | |
select * from output | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment