Link to home
Start Free TrialLog in
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.
ASKER CERTIFIED SOLUTION
Avatar of tim_cs
tim_cs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of minglelinch
minglelinch

ASKER

Nice answers. Thanks.