No, I did mean that the query I'm calling has parameters. Let me reduc
it to a simple form: I have a "query1" like this (with parameters) tha
I created in ACCESS. The query1 just selects a group of records from
huge table named "scores", asking me for which group I want th
scores.:
PARAMETERS [Geef groep:] Long;
SELECT scores.scoreID, scores.groep, scores.score
FROM scores
WHERE (((scores.groep)=[Geef groep:]));
When I want to calculate the median of scores based on this query, i
doesn't work:
SELECT query1.groep, Avg(query1.score) AS GemVanscore
DMedian("score","query1","[groep] = " & [groep]) AS Mediaan
FROM query1
GROUP BY query1.groep;
It asks me "Geef groep:" as expected, but then I get a message tha
query1 expects 1 parameter (which is logical). So the behaviour o
DMedian is different then Avg: whit Avg it is possible to calcultat
the average on a parameter-query, but how do I do this with DMedian? I
would really be helpfull to have a Median function that works as simpl
as Avg does...
Thanks for any help,
Ste
--
stef.pillaer
Tom Ellison - 21 Nov 2005 19:03 GMT
Dear Stef:
Your use of the DMedian function references Query1. The function invokes
that query, and that query requires a parameter. This is the source of your
problem.
Now, your invocation of DMedian provides a filter (the 3rd parameter).
Therefore, I recommend you create a new query, one much like Query1, but
without the parameter:
SELECT scores.scoreID, scores.groep, scores.score
FROM scores
Then change your Query2 so the above query is referenced as the second
parameter in the call to DMedian.
Can you see that your DMedian call already contains the filter (the 3rd
parameter) that is duplicated by the parameter in Query1? Can you see this
is a potential source of conflict, and is at best unnecessary?
Tom Ellison
> No, I did mean that the query I'm calling has parameters. Let me reduce
> it to a simple form: I have a "query1" like this (with parameters) that
[quoted text clipped - 24 lines]
> Thanks for any help,
> Stef
stef.pillaert - 22 Nov 2005 07:58 GMT
I understand the conflict, and I understand now that I can solve it b
putting the parameters in the calling query instead of in query1. But
hoped there would be a way to make a median function that acts the sam
way as Avg: Avg works on query1 (even with the parameters in it), an
DMedian doesn't...
Thanks for the help,
Ste
--
stef.pillaer
Tom Ellison - 22 Nov 2005 08:11 GMT
Dear Stef:
DMedian is not one of the built in aggregate functions. When you invoke
Avg() it works within the context of the query's grouping and filtering.
When you invoke the custom function DMedian it cannot do so. You must pass
the desired filtering to this query.
To expect to be able to use a parameter query for the source of the DMedian
seems a bit severe. It isn't so much that DMedian doesn't work like Avg
(none of the domain functions are close replacements for aggregate
functions) but that you must specify to it the data source and filtering it
is to use. This filtering is not compatible with the parameter in your
source query.
So, did you try my suggestion? Did it help?
Tom Ellison
> I understand the conflict, and I understand now that I can solve it by
> putting the parameters in the calling query instead of in query1. But I
[quoted text clipped - 5 lines]
>
> Stef
stef.pillaert - 25 Nov 2005 08:36 GMT
Yes, thanks for all the help. I have to make some changes to my databas
to make things work, but in principle, it is OK.
Ste
--
stef.pillaer