For example suppose I have the following join
join on p.match_id = o.match_id
Could I specify instead that if p.match_id is even then
join on p.match_id = o.match_id - 1
But if it is odd then
join on p.match_id = o.match_id + 1
I have sequential match_id such that consecutive values represent a single match. Therefore to work out an opponent for a given match_id I need the above
Edited so it doesn’t use CASE. The subquery returns a table with one field: matchid (equals match_id+1 when match_id is even and match_id-1 when match_id is odd).
Since you mention that you are using one table and 2 sequentials ids for one pair of opponents, you can also use the following as a subquery or a view:
It will give you a table that you can then collerate to itself: