Hi all, I have a sql related question that I would really appreciate some help with. Example:
SELECT age
, weight_pounds AS 'lbs'
, days_since_ran AS 'd_l_ran'
, position_in_betting AS 'pos_in_bet'
, going
, trainer win % over the last 12 month
, jockey win % over the last 12 month
FROM historic_races
, historic_runners
WHERE race_type = 'Flat'
AND meeting_date >= '2012-01-01'
AND meeting_date <= '2012-04-01'
ORDER BY meeting_date ASC
I'm trying to create a select statement that will give me, among other things, a win percentage for the trainer and jockey.
Basically for a given horse in a given race I'd like to be able to see as a percentage how many wins that horses trainer and jockey have had in the X months prior to that event. Like in the example code above. (and a way of dealing with small sample sizes eg 1 win out of 1 race is 100% however that's very misleading, would be really really good)
I'm not sure if this forum is the place to ask but any help with this would be awesomel, I've been messing around with nested select statements all weekend and I'm no closer to a solution.
Thanks in advance.