SELECT player.id AS player_id, player.tag AS player_tag, player.lp_name AS player_lpname, player.country AS player_country, player.race AS player_mainrace, match.date, match.plb_id AS opponent_id, match.sca AS player_score, match.scb AS opponent_score, match.rca AS player_race, match.rcb AS opponent_race, match.event, match.eventobj_id, match.offline, match.sca - match.scb AS score, match.id AS match_id, opponent.tag AS opponent_tag, opponent.lp_name AS opponent_lpname, opponent.race AS opponent_mainrace, opponent.country AS opponent_country, event.fullname AS event_name, (rating_player.rating + 1::double precision) * 1000::double precision AS player_rating, rating_player."position" AS player_position, (rating_opponent.rating + 1::double precision) * 1000::double precision AS opponent_rating, rating_opponent."position" AS opponent_position, CASE WHEN (match.sca - match.scb) > 0 THEN true ELSE false END AS win, CASE WHEN (match.scb - match.sca) > 0 THEN true ELSE false END AS loss FROM player LEFT JOIN match ON player.id = match.pla_id LEFT JOIN player opponent ON match.plb_id = opponent.id LEFT JOIN event ON match.eventobj_id = event.id LEFT JOIN rating rating_player ON match.rta_id = rating_player.id LEFT JOIN rating rating_opponent ON match.rtb_id = rating_opponent.id UNION SELECT player.id AS player_id, player.tag AS player_tag, player.lp_name AS player_lpname, player.country AS player_country, player.race AS player_mainrace, match.date, match.pla_id AS opponent_id, match.scb AS player_score, match.sca AS opponent_score, match.rcb AS player_race, match.rca AS opponent_race, match.event, match.eventobj_id, match.offline, match.scb - match.sca AS score, match.id AS match_id, opponent.tag AS opponent_tag, opponent.lp_name AS opponent_lpname, opponent.race AS opponent_mainrace, opponent.country AS opponent_country, event.fullname AS event_name, (rating_player.rating + 1::double precision) * 1000::double precision AS player_rating, rating_player."position" AS player_position, (rating_opponent.rating + 1::double precision) * 1000::double precision AS opponent_rating, rating_opponent."position" AS opponent_position, CASE WHEN (match.scb - match.sca) > 0 THEN true ELSE false END AS win, CASE WHEN (match.sca - match.scb) > 0 THEN true ELSE false END AS loss FROM player LEFT JOIN match ON player.id = match.plb_id LEFT JOIN player opponent ON match.pla_id = opponent.id LEFT JOIN event ON match.eventobj_id = event.id LEFT JOIN rating rating_player ON match.rtb_id = rating_player.id LEFT JOIN rating rating_opponent ON match.rta_id = rating_opponent.id ORDER BY 1, 6, 16;