SELECT DISTINCT ON ("OBSERVATION_ID") * FROM observation LEFT JOIN "soilObs" USING ("OBSERVATION_ID") ORDER BY "OBSERVATION_ID", "SOILOBS_ID"