Thread: SELECT DISTINCT and count(1)
Hi. I need to do a select distinct userid from usertable,<more tables> where <conditions>; and then count the rows in the result How do I do that?
Thank you both for both for your replies. 2009/7/16 Maximilian Tyrtania <maximilian.tyrtania@onlinehome.de>: > am 16.07.2009 11:57 Uhr schrieb A B unter gentosaker@gmail.com: > >> Hi. >> I need to do a >> >> select distinct userid from usertable,<more tables> where <conditions>; >> >> and then count the rows in the result >> >> How do I do that? > > Try: > > select count(distinct(userid)) from usertable,<more tables> where > <conditions>; > > Best wishes from Berlin, > > Maximilian Tyrtania > > >
On Thu, Jul 16, 2009 at 11:57:56AM +0200, A B wrote: > > select distinct userid from usertable,<more tables> where <conditions>; > > and then count the rows in the result make it a subselect and count in the outer select: select count(*) as num from (select distinct...) dummy;