gpt4 book ai didi

sql - 当前时间戳 Redshift

转载 作者:行者123 更新时间:2023-12-05 02:05:32 31 4
gpt4 key购买 nike

当我从 redshift 选择 current_timestamp 时,我得到了一个值列表而不是一个值。

这是我的 SQL 查询

select current_timestamp 
from stg.table;

有人知道为什么我得到的是值列表而不是单个值吗?

最佳答案

这是您的查询:

select current_timestamp from stg.table

这会产生与表 stg.table 中一样多的行(因为那是 from 子句),其中一列始终包含当前日期/时间在每一行。另一方面,如果表不包含任何行,则查询不返回任何行。

如果您只需要一行,请使用不带 from 子句的标量子查询:

select current_timestamp as my_timestamp

关于sql - 当前时间戳 Redshift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63476610/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com