Pivot table without crosstab

From: Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com>
To: PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Pivot table without crosstab
Date: 2015-02-09 13:59:53
Message-ID: CAGWYGjXCFRhCV7crEoO-KOF+busDt+OiDHsA=-pWfm2r16s4Ew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

I have a little problem with SQL statement to get values from a table.
Given a table:

Name Val1 Val2 Val2
Smith 0 1 0
Smith 1 0 0
Smith 0 0 1
Roberts 1 0 0
Roberts 0 0 1

I need to get:
Name Val1 Val2 Val2
Smith 1 1 1
Roberts 1 0 1

Best regards

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Lukasz Brodziak 2015-02-09 14:46:30 Re: Pivot table without crosstab
Previous Message Bruce Momjian 2015-02-07 21:43:45 Re: modifying the source code