dbTalk Databases Forums  

Query ?

comp.database.ms-access comp.database.ms-access


Discuss Query ? in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tech
 
Posts: n/a

Default Query ? - 03-01-2004 , 10:22 AM






I have my table definition in the below manner

CompanyID, DateViewed, Views.

I need to get the sum of all the views of a particular company between
specified dates.

select sum(views),DateViewed from tblCompany group by
CompanyID having DateViewed between '02/23/2004' and '02/24/2004'

I get the following error :

Column 'tblCompany.DateViewed' is invalid in the HAVING clause because
it is not contained in either an aggregate function or the GROUP BY
clause.

Do I need to use a correlated query?

Reply With Quote
  #2  
Old   
Ray
 
Posts: n/a

Default Re: Query ? - 03-02-2004 , 07:50 AM






neeraj_bod (AT) yahoo (DOT) com (Tech) wrote in message news:<35130298.0403010822.4db13ba9 (AT) posting (DOT) google.com>...
Quote:
I have my table definition in the below manner

CompanyID, DateViewed, Views.

I need to get the sum of all the views of a particular company between
specified dates.

select sum(views),DateViewed from tblCompany group by
CompanyID having DateViewed between '02/23/2004' and '02/24/2004'

I get the following error :

Column 'tblCompany.DateViewed' is invalid in the HAVING clause because
it is not contained in either an aggregate function or the GROUP BY
clause.

Do I need to use a correlated query?
Hello Tech.

Apparently you are grouping the query to try and get
the information you need. Perhaps what you could do
is set up two queries. The first one to get the information
you need from your Between Dates statment in the
criteria field. And the other to display your group
information.

Just use the query your using now with all of the data,
but don't set it as a grouping query.

Then set up a second query, with the first as the source,
and use the grouping feature there to sum your views field.
Just leave out the date field so that you'll end up with
the total your looking for.

Happy hunting.

Ray


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.