0

in my table the structure is like that

TableA

first_column        second_column       third_column
wwwew                   frfrffee          rfffrfr
dddfdd                  fffrfrfr          rfddwdrv
etc

if users has not set the value of second_column i want to display the result of first_column but if users has specified the value of second_column i want to display the second_column value.

i tried where clause with 'and' & 'or' statement but it is not working.

second_column is child of first column so if users has set parent only then the output will be based on parent but if users has set parent as well as child or only child the output will be based on child input

1 Answer 1

2

I think you can accomplish what you're trying to do using the coalesce() function.

select coalesce(second_column, first_column) from TableA;
Sign up to request clarification or add additional context in comments.

2 Comments

i have a join statement so i am using where clause to choose the data can you please tell how i can do with where clause as query is very complicated and any changes will not give the proper output
Please post your very complicated query.

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.