I'm using Postgres 9.6.*
I have this:
street | first_name | last_name
1st | james | bond
1st | mr | q
1st | ms | m
2nd | man | with_golden_gun
I would like to get a list of distinct addresses and the first set of 'first_name' and 'last_name' for each.
my desired output:
street | first_name | last_name
1st | james | bond
2nd | man | with_golden_gun
I am grouping by street
, and trying MIN(first_name)
and MIN(last_name)
-- however -- using MIN there are cases for each group of unique street I can get seemingly random a mix-and-match first_name
and last_name
that may not be of the same row. Obviously, MIN
(minimum) isn't the right aggregator function here.
my question: how do I enforce that the first_name
and last_name
are from the same row?