From: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Query |
Date: | 2007-12-10 12:59:42 |
Message-ID: | 20071210135942.31f17904@webthatworks.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 10 Dec 2007 12:23:49 +0000 (GMT)
Ashish Karalkar <ashish_postgre(at)yahoo(dot)co(dot)in> wrote:
> Hello there,
> I am having data in table something like below:
>
> user_id type_id
> 1 1
> 1 2
> 2 1
> 3 3
> 4 3
> 5 1
> 1 10
> 7 6
>
> What i want is the count of all user group by type_id who are
> subscribed to only one type e.g
>
> type_id count
> 1 2
1 3
> 6 1
This is not to "only one type" or I didn't get the question.
Something like
create table pippo ( user_id int, type_id int);
insert into pippo values(1,1);
insert into pippo values(1,2);
insert into pippo values(2,1);
insert into pippo values(3,3);
insert into pippo values(4,3);
insert into pippo values(5,1);
insert into pippo values(1,10);
insert into pippo values(7,6);
select type_id, count(*) from pippo group by type_id having
count(*)=1;
10;1
6;1
2;1
--
Ivan Sergio Borgonovo
http://www.webthatworks.it
From | Date | Subject | |
---|---|---|---|
Next Message | Ted Byers | 2007-12-10 12:59:44 | Re: Simpler dump? |
Previous Message | Richard Huxton | 2007-12-10 12:44:09 | Re: Query |