query, probably needs window functions

From: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: query, probably needs window functions
Date: 2020-05-22 18:30:02
Message-ID: 037A65BF-4CFE-4EC0-A037-173C9DDF2A9C@elevated-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

given, let's say:

create table person (id int not null, name varchar);
create table phone (id int not null, person_id int not null, number varchar);

select person.*, phone.number from person join phone on (person.id = phone.person_id) order by...

How would you get results where only the first row for a person was filled in, with rest of that person's phones showing blanks for those columns? I'm guessing that window functions provide this capability, but I don't know how.

--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
https://www.linkedin.com/in/scottribe/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-05-22 18:34:55 Re: query, probably needs window functions
Previous Message David G. Johnston 2020-05-22 16:26:03 Re: How to get the OID of a view