Re: Pivot table without crosstab

From: Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com>
To: PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Pivot table without crosstab
Date: 2015-02-09 14:46:30
Message-ID: CAGWYGjW3w4W38BHVDZt=RcOS-xnmKTS5C1XjHNMkaSsA4hRYUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi again,

I got it already. all you need to do is to use SUM and CASE.

2015-02-09 14:59 GMT+01:00 Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com>:
> 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Marcel Ruff 2015-02-10 08:39:25 How to get some table entries from backup instance back to production instance
Previous Message Lukasz Brodziak 2015-02-09 13:59:53 Pivot table without crosstab