简体   繁体   中英

I want to add a new column using SELECT query and get a latest value from multiple columns in SQL

Outcome1 Outcome2 Outcome3 Outcome4 DESIRED OUTCOME CR CR CR C CR CR CR N CR N CR CR C C C C C C C CC CC CR CC CC CR

It seems you simply need the first not-null value. If so, You can use COALESCE function -

SELECT COALESCE(Outcome1, Outcome2, Outcome3, Outcome4)
  FROM your_table;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM