Re: SQL query question - Mailing list pgsql-general

From Roman Neuhauser
Subject Re: SQL query question
Date
Msg-id 20050203123754.GA10688@isis.wad.cz
Whole thread Raw
In response to SQL query question  ("Uwe C. Schroeder" <uwe@oss4u.com>)
List pgsql-general
# uwe@oss4u.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

pgsql-general by date:

Previous
From: Mike Rylander
Date:
Subject: Re: modifying views
Next
From: Bricklen Anderson
Date:
Subject: Re: Invalid headers and xlog flush failures