Hi everyone,
First post from a newbie. The query below works if I run it as a select query when I enter values direct, but I don't know how to take those same inputs from another table.
Here's the query:-
SELECT wkts3.Winner, Count(wkts3.Winner) AS CountOfWinner
FROM wkts3
WHERE (((wkts3.RunDiff)>10 And (wkts3.RunDiff)<30))
GROUP BY wkts3.Winner, wkts3.Inns, wkts3.Team1Wkts, wkts3.Team2Wkts
HAVING (((wkts3.Inns)=1) AND ((wkts3.Team1Wkts)=19));
If you're interested, what this does is take the current state of a cricket match and find the likelihood of the home ("Team1") or away ("Team2") team winning, or the match ending in a draw ("Drawn") - that information is shown in the field Winner of the table wkts3. RunDiff is the difference in total runs scored by each team, the innings (Inns) is either 1, 2, 3 or 4, and the final input is either Team1Wkts or Team2Wkts depending on which team is batting, and is always a number between 0 and 20.
Running this query with those values in the query above will give me a list which will look something like this:-
Team1 85
Team2 76
Drawn 73
So basically the query finds all of the the matches in wkts3 which had the same state, or very close, in terms of Innings, RunDiff and Team1Wkts/Team2Wkts, and counts how many resulted in a win for Team1, Team2 or were drawn. What I would like to do is take the inputs for the query from another table, InState. So for a particular record in InState, which will have a value in each record for the fields Inns, RunDiff and either Team1Wkts or Team2Wkts (one will have a value between 0 and 20, the other will be a null), take those values as inputs to the query and generate the same results as above.
I presume I need to change the query type and/or make a relationship between the two tables, but trial and error hasn't shown me the solution.
If I haven't explained this well enough please let me know - hopefully there's enough without requiring a knowledge of cricket!
Thanks,
Dave