0

I have a postgres view that returns records with either 'Y' or 'N' as the value, and I'd like to convert them to 'Yes' or 'No' before the final SQL results are returned. For instance:

    CREATE OR REPLACE VIEW transit_info AS 
 SELECT 
 ('Train Service:'::text || tblpoi_transit_info.train_service::text AS train_service,

I'd like to convert train_service to a 'Yes' or 'No' depending on the recorded value. Any way to do this easily? I've been experimenting with CASE statements but haven't really got the syntax down yet. Thanks.

1 Answer 1

1
SELECT 
    ('Train Service:'::text
    ||
    case tblpoi_transit_info.train_service::text
        when 'Y' then 'Yes' else 'No'
    end AS train_service,
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.