Какой оптимальный способ заменить несколько строк и вернуть результаты операций замены в одном столбце.
Следующий запрос работает отлично, однако он, очевидно, сгенерировал 5 столбцов.
SELECT
REPLACE(l.status, 'New Onboarding Request', '1. New Lead'),
REPLACE(l.status, 'Appointment Accepted', '2. Appointment Accepted'),
REPLACE(l.status, 'Accepted', '3. Property Eligible'),
REPLACE(l.status, 'Owner Accepted', '4. Terms Accepted'),
REPLACE(l.status, 'Onboarding', '5. Onboarding'),
l.id, o.name as partner, v.lat as latitude, v.lng as longitude, v.postcode,
l.status, v.bedrooms, v.bathrooms, "v"."houseOrFlat", to_char("v"."created_at", 'YYYYMMDD') as valuation_date, to_char("l"."created_at", 'YYYYMMDD') as referral_date, to_char("l"."updated_at", 'YYYYMMDD') as updated, v.estimated_nightly_rate, v.furnished FROM valuations v
LEFT JOIN agent_onboarding_requests l on v.id = l.valuation_id
INNER JOIN organisations o on o.id = l.organisation_id
WHERE l.organisation_id != 1
ORDER BY referral_date ASC