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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER