I have a table of golf match-ups taken from Betfair's downloadable CSV files of historical data. They look like this:
event selection
S. Garcia Garcia
S. Garcia Woods
P. Mickelson Mickelson
P. Mickelson Donald
E. Els McIlroy
E. Els Els
I need a query that provides the following output:
event selection_a selection_b
S. Garcia Garcia Woods
S. Garcia Woods Garcia
P. Mickelson Mickelson Donald
P. Mickelson Donald Mickelson
E. Els McIlroy Els
E. Els Els McIlroy
To conclude, the event name is just one of the players in the match-up. Within each match up there will be two players, how do I write a query that recognises that Garcia played Woods, Mickelson played Donald and Els played McIlroy?
Help! :-)
SELECT
g.event,
Min(g.selection) AS selection_a,
Max(g.selection) AS selection_b
FROM Golf_matches AS g
GROUP BY g.event
UNION ALL
SELECT
g.event,
Max(g.selection),
Min(g.selection)
FROM Golf_matches AS g
GROUP BY g.event
ORDER BY 1, 2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With