Using CASE in PostgreSQL to affect multiple columns at once
问题 I have a Postgres SELECT statement with these expressions: ,CASE WHEN (rtp.team_id = rtp.sub_team_id) THEN 'testing' ELSE TRIM(rtd2.team_name) END AS testing_testing ,CASE WHEN (rtp.team_id = rtp.sub_team_id) THEN 'test example' ELSE TRIM(rtd2.normal_data) END AS test_response ,CASE WHEN (rtp.team_id = rtp.sub_team_id) THEN 'test example #2' ELSE TRIM(rtd2.normal_data_2) END AS another_example In my particular query there are 5 fields whose output depends on whether rtp.team_id = rtp.sub_team