Avatar of minglelinch
minglelinch

asked on 

T-SQL select different columns based in null value

I have a table containing columns like

id
model
location
num1
num2
num3
...

I need to write a query to select id, model, location, CASE .....

In the CASE, I need to select num1 (if not null)  num2 (if num1 is null) num3 (if num1 and num2 are null)

or say select (if num1 not null) num1
                       (if num1 is null) num2
                       (if num1, num2 are null) num3

To reach my purpose, how should I write the query?

Thanks.
Microsoft SQL Server 2005.NET Programming

Avatar of undefined
Last Comment
minglelinch

8/22/2022 - Mon