Removing duplicates in a PostgreSQL array
Moof Mayeda
181

Hi,

just writing to note that the use of UNNEST() in SELECT clauses is considered deprecated and may be invalid in future releases of PostgreSQL.

There is an equivalent variant of your idea that moves the UNNEST() into the FROM clause and gets rid of the GROUP BY at the same time:

SELECT v.song_id, genre 
FROM versions v, LATERAL UNNEST(STRING_TO_ARRAY(v.genre_list, ‘, ‘)) AS genre;

Cheers,
 —Torsten

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.