| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Baxter Allen <baxter(dot)allen(at)gmail(dot)com> |
| Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: How to display multiple rows in 1 row |
| Date: | 2017-01-11 03:55:49 |
| Message-ID: | CAKFQuwZwRnqcHjCKc+seEPAbrkwna-vho1rw+EDZMsSN5kPhFw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Tuesday, January 10, 2017, Baxter Allen <baxter(dot)allen(at)gmail(dot)com> wrote:
>
> Instead, I would like the output for each individual to be all on a single
> row:
> individual _id valA valB _id valC valD
> 1 1.table_b 1 2 1.table_c 4 3
> 2 2.table_b 4 7 2.table_c 3 4
> 3 3.table_b 5 4 3.table_c 2 21
>
>
The other approach is to "GROUP BY individual" and wrap every other column
in an aggregate function that retains the first non-null value in the group
(of which there should only be one). I don't recall there being a built-in
to do this but I'm certain it can be manually added and examples found on
the internet.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Steve Midgley | 2017-01-11 04:01:52 | Re: How to display multiple rows in 1 row |
| Previous Message | David G. Johnston | 2017-01-11 03:40:57 | Re: How to display multiple rows in 1 row |