Add string to query result

Viewed 37

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?

1 Answers

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.

Related