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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on the IN sub-clause of the Having clause

Status
Not open for further replies.

Clipper4000

Programmer
Dec 13, 2004
5
US
I have a query which utilized the having clause like this:

Select ...
From ...
Group BY Account, ...
Having Account IN (1000, 2000, 3000)

This query worked.

What I want to be able to do is to use a function to return the values in the IN sub-clause. Could this be done in Access SQL?

I am assuming the items in the IN clause correspondent to an array. I can setup a function that will return me the array. However, I am having trouble calling the function in the IN clause.

I will be very much appreciated if anyone can point me to the correct calling syntax.
 
First, instead of:
Having Account IN (1000, 2000, 3000)
you may use:
WHERE Account IN (1000, 2000, 3000)
because you don't use aggregate function in the condition.

You can't build a SQL with a condition like this:
WHERE Account IN (someFunction())

One way is to create a Boolean function returning true if the parameter is in the "array", and then the condition is:
WHERE myFunction([Account])=True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top