RECURSIVE (43321721355).jpg

Recurcive CTEs (Common Table Expressions) are a powerful construct within PostgreSQL, it defined in the WITH clause. CTEs allows to work with temporary set of data and transform it. In our case query collects all rags except hat from the girl, and combines it one set without duplicates :) "" is not equal operator "array_agg" conctatinates input values into array "dictinct" removes duplicates values I've made an example to play with CTEs <a href="http://sqlfiddle.com/#!17/f2ea4c/1" rel="noreferrer nofollow">sqlfiddle.com/#!17/f2ea4c/1</a>
Artist: Exey Panteleev from Moscow, Russia. License: CC BY 2.0. Source
Save this to a board · free account
