ms access product function

H

Honestcon

A simple query - I want to multiply two fields, CategoryPrice and ProductQua,
from my Extras table.
This is the code I wrote:
SELECT EXP(SUM(LOG(CategoryPrice))), ProductQua
FROM Extras

And this is the error I got:
You tried to execute and expressio that does not include the specified
expression 'ProductQua' as par of an aggregate function.

How do I rectify this, please.
 
V

vanderghast

You missed the GROUP BY clause, probably:


SELECT EXP(SUM(LOG(CategoryPrice))), ProductQua
FROM Extras
WHERE categeryPrice >0
GROUP BY ProductQua



Else, what is the role of ProductQua, assuming your table has

CategoryPrice, ProductQua
2 10
3 14


the result would be:

EXP(SUM(LOG(CategoryPrice))), ProductQua
6, ???



??? being what ProductQua will be used? 10? 14?

That is why SQL requires that either ProductQua is in the GROUP BY, either
that you aggregate it (such as MAX(ProductQua) )




Vanderghast, Access MVP
 
T

Tom van Stiphout

On Fri, 19 Jun 2009 05:16:01 -0700, Honestcon

Select CategoryPrice * ProductQua
From Extras

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top