| From: | Markus Schulz <msc(at)tastatur-junkie(dot)de> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: SQL query question |
| Date: | 2005-02-03 11:48:36 |
| Message-ID: | 200502031248.36407.msc@tastatur-junkie.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Am Donnerstag, 3. Februar 2005 08:32 schrieb Uwe C. Schroeder:
> 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
> It got to be possible to get a query like that, but somehow it eludes
> me tonight.
>
> Any pointers are greatly appreciated.
>
> UC
select user_id,image_type, count(id)
from <table>
group by user_id,image_type
should do it.
--
Markus Schulz
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mike Rylander | 2005-02-03 11:49:39 | Re: modifying views |
| Previous Message | Richard Huxton | 2005-02-03 10:53:20 | Re: Problem with the sequence |