[AccessD] complex query!!

Gustav Brock Gustav at cactus.dk
Fri Jan 14 02:23:42 CST 2005


Hi Pedro

Bob is right that the AVG() is not needed.

Further, by second thought, Group By on the values may cause strange
results if they are not unique. If so you should Group By on the ID of
the tables.

/gustav

>>> pedro at plex.nl 13-01-2005 20:51:49 >>>
Hello Gustav and Rob,

thanks for the help.
GROUP BY on the fields to, was something i must had noticed myself.

Greetings Pedro



----- Original Message ----- 
From: "Bob Hall" <rjhjr at cox.net>
To: <accessd at databaseadvisors.com>
Sent: Wednesday, January 12, 2005 10:20 PM
Subject: Re: [AccessD] complex query!!


> On Wed, Jan 12, 2005 at 09:05:41PM +0100, Gustav Brock wrote:
> > Hi Pedro
> > 
> > Bob is right but you need to Group By on the fields too:
> > 
> >   SELECT 
> >     Avg(tblGroup1.FieldA+tblGroup2.FieldB)/2 AS Avg2
> >   FROM 
> >     tblGroup1,
> >     tblGroup2
> >   GROUP BY 
> >     tblGroup1.FieldA,
> >     tblGroup2.FieldB;
> 
> If that's what Pedro wants, then he doesn't need Avg(). 
> SELECT (tblGroup1.FieldA+tblGroup2.FieldB)/2 AS Avg2




More information about the AccessD mailing list