Thread: a change of query
select
distinct cp.person_id from cluster_person cp, cluster c where cp.cluster_id = c.cluster_id and c.c_id = 1can this query be changed to give just the row count?( of the distinct rows )
yes: i am aware of count() but this wont count the distinct rows - I can however achive this with an nested person_id in(select... etc but that slows things down big time!!!!
the above quey gives me my resultset asap - is there a way to get just the number of rows with the same speed
My thoughts are that I could just make a plpgsql function with a GET Diagniostics ROW_COUNT -
thoughts?
James
On Tue, 2003-02-25 at 14:03, James Cooper wrote: > select distinct cp.person_id from cluster_person cp, cluster c where > cp.cluster_id = c.cluster_id and c.c_id = 1 > > can this query be changed to give just the row count?( of the distinct > rows ) select count(distinct cp.person_id) from ... Is that what you were after? Brad Hilton VPOP Technologies, Inc.
On Tue, 2003-02-25 at 17:03, James Cooper wrote: > select distinct cp.person_id from cluster_person cp, cluster c where > cp.cluster_id = c.cluster_id and c.c_id = 1 > > can this query be changed to give just the row count?( of the distinct > rows ) :) So close select count(distinct cp.person_id) from... -- Rod Taylor <rbt@rbt.ca> PGP Key: http://www.rbt.ca/rbtpub.asc
----- Original Message -----From: James CooperTo: sqlSent: Tuesday, February 25, 2003 3:03 PMSubject: [SQL] a change of queryselect
distinct cp.person_id from cluster_person cp, cluster c where cp.cluster_id = c.cluster_id and c.c_id = 1can this query be changed to give just the row count?( of the distinct rows )
yes: i am aware of count() but this wont count the distinct rows - I can however achive this with an nested person_id in(select... etc but that slows things down big time!!!!
the above quey gives me my resultset asap - is there a way to get just the number of rows with the same speed
My thoughts are that I could just make a plpgsql function with a GET Diagniostics ROW_COUNT -
thoughts?
James