将字符串添加到查询结果

发布于 2025-01-30 18:26:24 字数 822 浏览 4 评论 0原文

我有以下查询:

select point_delivery_number, bin(time,1h) as time , AVG(self_coverage) as self_coverage , AVG(generation) as generation , AVG(consumption) as consumption
from "energy_datapoints"."formatted_group_raw"
GROUP BY point_delivery_number, bin(time, 1h) 
ORDER BY time desc

结果如下:

”在此处输入图像说明”

我想在指示那是UTC时间格式

结果的时间中添加z应该是:

AT..... | 2021-05-31 21:00:00.00000Z | ... | ... | ... 

我尝试使用Concat

CONCAT(bin(time,1h), 'Z') as time

说:

行1:31:意外参数(Timestamp,varchar(1))功能 'concat'

可能有更好的方法吗?

I have the following query:

select point_delivery_number, bin(time,1h) as time , AVG(self_coverage) as self_coverage , AVG(generation) as generation , AVG(consumption) as consumption
from "energy_datapoints"."formatted_group_raw"
GROUP BY point_delivery_number, bin(time, 1h) 
ORDER BY time desc

The result is following:

enter image description here

I want to add an Z to the time to indicate thats an UTC time format

Result should be then:

AT..... | 2021-05-31 21:00:00.00000Z | ... | ... | ... 

I tried to use CONCAT

CONCAT(bin(time,1h), 'Z') as time

It says:

line 1:31: Unexpected parameters (timestamp, varchar(1)) for function
'CONCAT'

Is there maybe an better way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待圉鍢 2025-02-06 18:26:24

这是一个适合您格式的示例:

SELECT FORMAT(GetUtcDate(),'yyyy-MM-dd HH:mm:ss.ffffZ') FROM yourTable

用您的时间列替换getutcdate()

Here is an example with the right formatting for you:

SELECT FORMAT(GetUtcDate(),'yyyy-MM-dd HH:mm:ss.ffffZ') FROM yourTable

Replace the GetUtcDate() with your time column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文