Re: SQL

From: "cristi" <cristi(at)dmhi(dot)ct(dot)ro>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: SQL
Date: 2002-11-12 10:53:15
Message-ID: 002501c28a39$b49c3420$7201a8c0@aaa
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Amazing!
Brilliant solution!
You make me very happy!

Thanks!

> wrote:
> >This is the contents of the table:
> >marca mo
> >1 C
> >2 C
> >[...]
> >
> >I need a SQL interogation with following results:
> >marca concedii boala obligatii
> > 1 2 1 0
> > 2 1 0 0
> > 4 0 1 0
> > 5 0 0 1
>
> SELECT marca,
> SUM(CASE mo WHEN 'C' THEN 1 ELSE 0 END) AS concedii,
> SUM(CASE mo WHEN 'B' THEN 1 ELSE 0 END) AS boala,
> SUM(CASE mo WHEN 'O' THEN 1 ELSE 0 END) AS obligatii
> FROM yourtable
> GROUP BY marca
> ORDER BY marca;
>
> HTH.
> Servus
> Manfred
>

In response to

  • Re: SQL at 2002-11-12 09:28:46 from Manfred Koizar

Browse pgsql-novice by date

  From Date Subject
Next Message Rory Campbell-Lange 2002-11-12 11:50:34 return column id from insert
Previous Message Henshall, Stuart - Design & Print 2002-11-12 09:57:33 Re: Delete column