Search code examples
clickhouse

how to concat two columns value in clickhouse


I have two columns, one with date (yyyy-mm-dd) Nullable(Date) and another with hour (hh) Nullable(UInt8), and I need to write a select that would return me {date}T{hour}:00:00Z. In postgresql the query would be SELECT concat(date, 'T',hour,':00:00Z') FROM table. Is it possible to do the same in Clickhouse?


Solution

  • We can try using the toString() function here:

    SELECT toString(date) || 'T' || leftPad(toString(hour), 2, '0') || ':00:00Z' AS ts
    FROM yourTable;