Re: SQL query question

From: Roman Neuhauser <neuhauser(at)chello(dot)cz>
To: "Uwe C(dot) Schroeder" <uwe(at)oss4u(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL query question
Date: 2005-02-03 12:37:54
Message-ID: 20050203123754.GA10688@isis.wad.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

# uwe(at)oss4u(dot)com / 2005-02-02 23:32:28 -0800:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Maybe it's to late for me to think correctly (actually I'm sure of
> that). I'm going to ask anyways. I have a table like
>
> id int4
> user_id int4
> photo varchar
> image_type char(1)
>
> where image_type is either G or X
> What I want to do is have ONE query that gives me the count of images
> of each type per user_id.
> So if user 3 has 5 photos of type G and 3 photos of type X
> I basically want to have a result 5,3

SELECT COUNT(*) FROM t GROUP BY t.user_id, t.image_type

--
If you cc me or remove the list(s) completely I'll most likely ignore
your message. see http://www.eyrie.org./~eagle/faqs/questions.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Postgre.News.Firma 2005-02-03 13:02:56 ADO adCmdStoredProc PlPgSql-SP Parameters
Previous Message Mike Rylander 2005-02-03 11:49:39 Re: modifying views