Find player's latest match whether player was the winner or loser I have a table of match results with the following fields (and many more):

id
date_played
begin_time
end_time
winner_id   &lt;-----foreign key into user.id
win_start_hcp
win_end_hcp
loser_id    &lt;-----foreign key into user.id
loser_start_hcp
loser_end_hcp


I want to find the win_end_hcp for the last match played by user.id=X, whether he was a winner or a loser of that match.
Are you looking for this,

select top(1)  isWinner,  win_end_hcp
from
(
select 1 isWinner, end_time,  win_end_hcp from table1
where winner_id=X
union ALL
select 0 isWinner, end_time,  win_end_hcp from table1
where loser_id=X
)t4
order by t4.end_time desc