Google bigquery 三个日期之间的日期差

Google bigquery 三个日期之间的日期差,google-bigquery,Google Bigquery,我正在使用遗留sql计算3个日期之间的差异。 我们的想法是在两天内找出差异,当第二个日期为空时,应该取第三个日期 已生成下面的查询,但错误为 SELECT asset_tag , receive_date , first_time , second_time , location , location_country , m_n12, display, Datediff( Case When second_time is null Then first_time When first_t

我正在使用遗留sql计算3个日期之间的差异。 我们的想法是在两天内找出差异,当第二个日期为空时,应该取第三个日期

已生成下面的查询,但错误为

SELECT
asset_tag , receive_date  , first_time , second_time , location , 
location_country ,
m_n12, display,
Datediff(  Case When second_time  is null Then first_time
When first_time  is null Then second_time
When first_time  > second_time  Then second_time
Else first_time
END as first_date ,receive_date )
FROM [abc_table]
where type in ('Laptop', 'Monitor', 'Desktop')
and receive_date >'2017'

在第8行第9列遇到“AS”。应为:“)”

大小写
表达式中删除别名:

DATEDIFF(CASE WHEN second_time IS NULL THEN first_time
              WHEN first_time IS NULL THEN second_time
              WHEN first_time > second_time THEN second_time
              ELSE first_time END, receive_date)
别名在对
DATEDIFF
的整个函数调用中可能有意义,但它不属于函数调用本身