PDA

View Full Version : Query Help


ggpagels
2nd November 2003, 02:21.10 PM
I use reports built on queries to do daily screening of races for spot plays. I would like to screen for races in which two horses have certain characteristics(ie. K1 with nKrat>=110 and K2 with rWKSC = 1). Is writing a query based on another query the best way to accomplish this?

Donnie
2nd November 2003, 03:51.40 PM
Think of a query built on a query as a sub-query of that first query....they must first be eligible to be returned in the first query, then they must meet the "requirements" of the second query.

Your first query may throw up races that meet your "play" requirements, while your second query would tell you if there are any horses eligible to be played within those races.

MikeDee
2nd November 2003, 04:00.58 PM
a OR creitera should do it

In the first row put your K1 with nKrat>=110

in the second row of the query put your K2 with rWKSC = 1

this will give you runners that meet either one of the above.

Be sure that if you have any other crietria set they you put the same value in each row.

For example lets say you are only filtering for santa anita then you need to put SA in the tTRK field in BOTH rows. Otherwise you would get only SA for 1 of your requirements and all of the tracks in your dB for the other.

ggpagels
3rd November 2003, 11:57.00 AM
Thanks, Donnie and MikeDee. I think one query with an "OR" will get me what I want but won't it also get me races where K1's have a nKrat>=110 and other races where K2 have rWKSC = 1 along with races where there are both K1 and K2 with the above criteria. I think a query that selects races with K1 with nKrat >=110 and all the horses in those races and another query that selects K2 with rWKSC=1 from the first query is more restrictive. Whether or not I can build a query on a query will be the challenge, however.

Donnie
3rd November 2003, 12:00.45 PM
Jerry-
Build your first query, then when you go to build the second one, when the Show Tables box opens up in design view, change the tab on top to queries instead of tables....then design your second query based on the first! You can design queries on tables or other queries!!

MikeDee
3rd November 2003, 12:07.30 PM
Yes you could have races that meet condition 1 only OR condition 2 only OR where condition 1 and condition 2 are both met. Why wouldn't you want want the races where both conditions are met?

MikeDee
3rd November 2003, 12:11.14 PM
In Donnies approach the second query will only be looking at the races where condition 1 was has been met. It is my understanding that you want any race where either conditon is met.

ggpagels
3rd November 2003, 12:32.40 PM
Mike, sorry I was a little vague. I'm looking for races where the K1 horse has a >=110 rating and the K2 also meets certain criteria(ie. rWKSC = 1 ) in the same race. I screen 9 tracks every day for possible exacta and trifecta plays with the K1 and K2 in the one and two holes.