View Single Post

   
  #5 (permalink)  
Old 02-28-2008, 09:26 AM
Peter H. Coffin
 
Posts: n/a
Default Re: group by problem

On Tue, 20 Mar 2007 16:38:36 +0100, Bob Bedford wrote:
> Hi all, on a query I've this result:
> 69 86
> 77 84
> 112 91
> 114 91
> 119 91
> 124 92
> 125 92
> 133 93
> ...
>
> first is the idfolder, second is the idclient.
>
> Now When I do a group by idfolder, I've a total of 77 rows (see the result
> above for the first part). If I do a group by idclient, then I only get 3
> results
>
> Why ? Have you an idea ?
>
> Here is the query:
> select folder.idfolder, folder.idclient from folderstatus
> inner join statustype on folderstatus.idstatustype=statustype.idstatus
> inner join folder on folderstatus.iddossier = folder.idfolder
> group by folder.idfolder
> having max(idstatustype) = (select idstatus from statustype where
> statustype.name like '%search%' limit 0,1)
>
> if I do a group by folder.idclient, then I only get 3 rows instead of about
> 50.


You haven't told us anything about your statustype table, its contents,
etc, yet, and you're selecting only SOME of the records, based on that.
How many, we certainly cannot say.

--
Cunningham's Second Law:
It's always more complex than you expect, even when you take
Cunningham's Second Law into account.
Reply With Quote