I had this question at a job interview yesterday and although it seemed pretty straight fwd I couldn't figure it out and it's kept me awake all night thinking about it.
The system records data about a scrabble league there is a members table, a games table and a joining member_games table.
members: member_id, name : pk(member_id)
member_games: game_id, member_id, score : pk(game_id, member_id)
games: game_id, location, date : pk(game_id)
members
1, mick
2, keith
3, charlie
member_games
1, 1, 50
1, 2, 60
2, 1, 45
2, 3, 105
3, 1, 30
3, 3, 120
game
1, london, 2012-12-01
2, richmond, 2012-12-02
3, leeds, 2012-12-03
How do you formulate an SQL query to find out the number of wins for the member_id = 1?