I should know this - but I don't, can anyone help me with a syntax plz.
Let's say I'm tracking runners in a cross-country relay race, I've got a main join table that associated runners with races... and a runners table that tells me where/when they started their leg and where/when they ended... there are also check-points that are logged along the route.
It's a requirement that each runner have a start and end point - HOWEVER, this is not always being entered correctly* - I need a query to pull out runners who DO NOT have BOTH types of entries in a race.
(*yes I am fixing the data entry side of things)
Thx
STRUCTURE:
RACE TABLE
raceID (int)
runnerID (int)
STOPS TABLE
runnerID (int)
stopTypeID (int) -- fk to stop type
when (timestamp)
sequence (smallint)
I don't really "have" anything yet- because I'm stymed by what I need...
the basic Q to get runners and race logs is this
SELECT *
FROM RACES R
JOIN STOPS S ON S.runnerID = R.runnerID
WHERE R.RaceID = 133
RESULTS
1 = start
2 = check point
3 = rest point
4 = end
RACEID RUNNERID STOPTYPEID
133 21 1
133 21 4
133 21 3
133 21 2
133 21 2
133 21 2
133 21 2
133 21 2
133 23 2
133 23 2
133 23 2
133 23 2
133 23 4
Notice runner 23 is missing a type '1' (start) I want a list of Runners in a race that are missing data... If i say 1's and 4's are REQUIRED....
(thx and sorry for not posting the 'data' needed)