In response to Nilesh Govindarajan :
> Hi,
>
> I want to find out the userid, nodecount and comment count of the userid.
>
> I'm going wrong somewhere.
>
> Check my SQL Code-
Check my example:
test=*# select * from u;id
---- 1 2 3
(3 rows)
test=*# select * from n;uid
----- 1 1 1 2 2 3
(6 rows)
test=*# select * from c;uid
----- 1 2 2 3 3 3
(6 rows)
test=*# select foo.id, foo.n_count, count(c) from (select u.id, count(n)
as n_count from u right join n on (n.uid=u.id) group by 1) foo left join
c on foo.id=c.uid group by id, n_count;id | n_count | count
----+---------+------- 1 | 3 | 1 2 | 2 | 2 3 | 1 | 3
(3 rows)
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99