Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Specified Expression not included as part of aggregate Function

Posted on 2006-11-13
6
Medium Priority
?
305 Views
Last Modified: 2008-02-01
Hello,

I have a database with Prioperties (PropertyID) and Years.  

I am trying to build a query that will give me the Sum of the RoomsCoorExp + FBExp for each Property.  I've got that part working fine.  I don't want to include any of the RoomsCorrExp or FB Exp if the GrossRevenue = 0 for that particular year.

I tried entering [GrossRevenues]<>0 as the criteria for my expression, and I get the Error "You tried to execute a query that does not include the specified expression 'Not [GrossRevenues]=0' as part of an aggregate function.

The SQL that does work (before I try to add in the GrossRevenue critearia) is:
SELECT tblFinancial.PropertyID, tblMASTER.HotelName, Sum([tblFinancial].[RoomsCorrExp]+[tblFinancial].[FBExp]) AS TotalCapEx
FROM tblFinancial INNER JOIN tblMASTER ON tblFinancial.PropertyID = tblMASTER.PropertyID
GROUP BY tblFinancial.PropertyID, tblMASTER.HotelName;

Any thoughts?

Thanks!
cdmac
0
Comment
Question by:cdmac2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17933447
An alternative way, try this
though it might still complain due to +

SELECT tblFinancial.PropertyID, tblMASTER.HotelName, Sum([tblFinancial].[RoomsCorrExp])+Sum([tblFinancial].[FBExp]) AS TotalCapEx
FROM tblFinancial INNER JOIN tblMASTER ON tblFinancial.PropertyID = tblMASTER.PropertyID
GROUP BY tblFinancial.PropertyID, tblMASTER.HotelName
0
 
LVL 1

Author Comment

by:cdmac2
ID: 17933547
Rockiroads,

Thanks for your response.  The Statment I wrote above DOES work (I tried your statement too, and it also works).  What I can't figure out how to do is get the "GrossRevenues<>0" Criteria in there.

Thx!
0
 
LVL 44

Accepted Solution

by:
GRayL earned 2000 total points
ID: 17933607
SELECT tblFinancial.PropertyID, tblMASTER.HotelName, Sum([tblFinancial].[RoomsCorrExp])+Sum([tblFinancial].[FBExp]) AS TotalCapEx
FROM tblFinancial INNER JOIN tblMASTER ON tblFinancial.PropertyID = tblMASTER.PropertyID
WHERE <WhichTable?>.GrossRevenues <> 0
GROUP BY tblFinancial.PropertyID, tblMASTER.HotelName;

Add the third line and be sure to replace <WhichTable?> with the correct table name - either tblFinancial or tblMaster
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 65

Expert Comment

by:rockiroads
ID: 17933654
ok, gotcha
I see GRayL has given u the answer, obviously too slow in responding today
I think it has something to do with tree cutters!

0
 
LVL 1

Author Comment

by:cdmac2
ID: 17933679
Worked like a charm!

I'm feeling a little off myself.  The solution was very simple.. for some reason I was stuck in the HAVING statemnt.

Thanks guys!


0
 
LVL 44

Expert Comment

by:GRayL
ID: 17933746
Thanks, glad I could help.  

rocki, the vision is slowly improving.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question