UNION ALL date on the same row
You can use FULL JOIN like this:


SELECT
    COALESCE(a1.t, a2.t) as t,
    a1."1489",
    a2."1616"
FROM
(
    select 
        date_trunc('hour', TO_TIMESTAMP(created / 1000)::timestamp) as t, 
        COALESCE(count(*), 0) as "1489"
    from actions
    where group_id = 1489
        and TO_TIMESTAMP(created / 1000)::timestamp &gt;= current_date-7
    group by 1
) as a1
FULL JOIN
(
    select 
        date_trunc('hour', TO_TIMESTAMP(created / 1000)::timestamp) as t, 
        COALESCE(count(*), 0) as "1616"
    from actions
    where group_id = 1616
        and TO_TIMESTAMP(created / 1000)::timestamp &gt;= current_date-7
    group by 1
) as a2 ON (a1.t=a2.t)
ORDER BY 1;


Or just use CASE:


SELECT
    date_trunc('hour', TO_TIMESTAMP(created / 1000)::timestamp),
    SUM(CASE WHEN group_id=1489 THEN 1 ELSE 0 END) as "1489",
    SUM(CASE WHEN group_id=1616 THEN 1 ELSE 0 END) as "1616"
FROM actions
WHERE 
    group_id in (1489, 1616)
    AND TO_TIMESTAMP(created / 1000)::timestamp &gt;= current_date-7
GROUP BY 1
ORDER BY 1;