开始使用免费开始使用

使用 CURRENT_TIMESTAMP

在分析型查询中,另一类常见问题是基于当前日期或时间,查找某个时间区间内的数据。尽管本题数据中的日期都在过去,但在实际工作中,您经常会处理每天更新、甚至持续流式写入的数据表。

本练习是课程的一部分

BigQuery 入门

查看课程

练习说明

  • 完成查询,使用 DATE_DIFF() 函数计算前 5 个订单相对于当前日期的天数差。

交互式实操练习

通过完成这段示例代码来试试这个练习。

-- Finish the query to find the difference in days

SELECT
	-- Add in the function to find the difference between two dates
	___(
      -- Finish the statement with the correct date part
      EXTRACT(___ FROM order_purchase_timestamp),
      -- Add the function to find the current date
      ___(),
      DAY
    )
FROM 
	ecommerce.ecomm_order_details
LIMIT 5;
编辑并运行代码