2 changed to a CROSS JOIN (thanks ypercube)
source | link

You could use LATERAL, like in this querythis query:

SELECT DISTINCT
  x.n
FROM
  atable
  CROSS JOIN LATERAL (
    VALUES (a), (b), (c), (d)
  ) AS x (n) ON 1=1
;

The LATERAL keyword allows the right side of the join to reference objects from the left side. In this case, the right side is a VALUES constructor that builds a single-column subset out of the column values you want to put into a single column. The main query simply references the new column, also applying DISTINCT to it.

You could use LATERAL, like in this query:

SELECT DISTINCT
  x.n
FROM
  atable
  JOIN LATERAL (
    VALUES (a), (b), (c), (d)
  ) AS x (n) ON 1=1
;

The LATERAL keyword allows the right side of the join to reference objects from the left side. In this case, the right side is a VALUES constructor that builds a single-column subset out of the column values you want to put into a single column. The main query simply references the new column, also applying DISTINCT to it.

You could use LATERAL, like in this query:

SELECT DISTINCT
  x.n
FROM
  atable
  CROSS JOIN LATERAL (
    VALUES (a), (b), (c), (d)
  ) AS x (n)
;

The LATERAL keyword allows the right side of the join to reference objects from the left side. In this case, the right side is a VALUES constructor that builds a single-column subset out of the column values you want to put into a single column. The main query simply references the new column, also applying DISTINCT to it.

1
source | link

You could use LATERAL, like in this query:

SELECT DISTINCT
  x.n
FROM
  atable
  JOIN LATERAL (
    VALUES (a), (b), (c), (d)
  ) AS x (n) ON 1=1
;

The LATERAL keyword allows the right side of the join to reference objects from the left side. In this case, the right side is a VALUES constructor that builds a single-column subset out of the column values you want to put into a single column. The main query simply references the new column, also applying DISTINCT to it.