detect what columns to select depending on a column value of the same table
Sounds like you need to use CASE WHEN expression, which is well documented. So case when x = y then select this else select that etc.