From: Scott Ribe <scott_ribe@elevated-dev.com>
To: pgsql-general@postgresql.org
Subject: query, probably needs window functions
Date: Fri, 22 May 2020 12:30:02 -0600
Message-ID: <037A65BF-4CFE-4EC0-A037-173C9DDF2A9C@elevated-dev.com> (raw)
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@elevated-dev.com
https://www.linkedin.com/in/scottribe/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: scott_ribe@elevated-dev.com
Subject: Re: query, probably needs window functions
In-Reply-To: <037A65BF-4CFE-4EC0-A037-173C9DDF2A9C@elevated-dev.com>
References: <037A65BF-4CFE-4EC0-A037-173C9DDF2A9C@elevated-dev.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox