как это реализовать, если case возвращает только одно поле. Для каждого поля отдельный case с этими же условиями?
SELECT COALESCE(x.txt1, trim(r2.team_name)) AS testing_testing , COALESCE(x.txt2, trim(r2.normal_data)) AS test_response , COALESCE(x.txt3, trim(r2.normal_data_2)) AS another_example FROM rtp JOIN rtd2 r2 ON <unknown condition> -- missing context in question LEFT JOIN ( SELECT 'testing'::text AS txt1 , 'test example'::text AS txt2 , 'test example #2'::text AS txt3 ) x ON rtp.team_id = rtp.sub_team_id; если типы одинаковые SELECT x.combo[1], x.combo[2], x.combo[3] FROM ( SELECT CASE WHEN rtp.team_id = rtp.sub_team_id THEN '{test1,test2,test3}'::text[] ELSE ARRAY[trim(r2.team_name) , trim(r2.normal_data) , trim(r2.normal_data_2)] END AS combo FROM rtp JOIN rtd2 r2 ON <unknown condition> ) x;
Обсуждают сегодня