Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Expression Error ")" . . ?

Status
Not open for further replies.

Rick4077

Technical User
Oct 19, 2004
149
US
I've been racking my brain on this . . . why doesn't it work? Error is extra ")" in query expression! I've tried a zillion different ways to correct it.

Thanks . . . Rick

Code:
SELECT C.OfcName, S.ListName, S.SellName, 

IIF(Sum(S.ListName) Like (C.OfcName &"*")) And ((S.SellName) Not Like (C.OfcName &"*")),S.SalePrice*2,0)) AS TSODV

FROM CBAll AS C, SCMLS AS S 

GROUP BY CBAll.OfcName;
 
How/why are you summing ListName?

The other problem is with the parens. You are closing the iif statement with the RED parens:

SELECT C.OfcName, S.ListName, S.SellName,

IIF(Sum(S.ListName) Like (C.OfcName &"*")) And ((S.SellName) Not Like (C.OfcName &"*")),S.SalePrice*2,0)) AS TSODV

FROM CBAll AS C, SCMLS AS S

GROUP BY CBAll.OfcName;

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
I don't know . . . I'm totally lost with Access' required ))))'s . . .

It's beyond me.

thanks . . . rick

 
the required parens are usually just for joins, this should work:

iif((Sum(S.ListName) Like C.OfcName & "*") AND (S.SellName Not Like C.OfcName&"*"), S.SalePrice * 2, 0)


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
Summing a name makes no sense for me !
You wanted this ?
Sum(IIf(S.ListName Like C.OfcName & '*' AND S.SellName Not Like C.OfcName & '*', S.SalePrice * 2, 0))

the required parens are usually just for joins
???
For me, parens are mandatory only when you mix AND and OR operators ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hey everyone. Thanks much.

I'm begenning to get results.


Just a little more tweaking.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top