GCP BigQuery -SQL 最佳实践
1. 使用 with 语句写多个SQL语句
2. 使用 begin with 语句写多个SQL语句
3. 提取某daily history表中最新的 image date的数据,进行计算
使用declare 函数进行声明后,在 where 语句中用 unnest 函数
declare max_image_dt array<date>;
set max_image_dt = array(SELECT
Max(IMAGE_DT)
FROM
`usecase.datasets.table_DH` where image_dt > (current_date()-10)
)
;
select id
,accountNumber
,balance
,image_dt
from `usecase.datasets.table_DH`
where image_dt in unnest(max_image_dt)

浙公网安备 33010602011771号