0

i would like to create table from

SELECT 
a.value_text, 
a.value_free_text,
a.value_date,
a.value_number
FROM survey_user_input_line a 
LEFT JOIN survey_label b on b.id = a.value_suggested
WHERE a.survey_id = %s
ORDER BY question_id, a.user_input_id,  id, value_suggested_row

enter image description here

to

enter image description here

can anybody tell me how to code it

1 Answer 1

1

You may use a chained call to COALESCE, making sure to cast all columns to a common data type (text makes the most sense here):

SELECT *, COALESCE(value_text, value_free_text, value_date::text,
                   value_number::text) AS all_value
FROM yourTable;
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.