SQL Fiddle
Настройка схемы MS SQL Server 2017 :
create table Temp
(
col1 nvarchar(50),
col2 nvarchar(50),
col3 nvarchar(50)
)
insert into temp (col1,col2,col3) values (null, null, 'W')
insert into temp (col1,col2,col3) values (null, null, null)
insert into temp (col1,col2,col3) values ('A', 'B', 'W')
Запрос 1 :
select * from temp
where COALESCE(col1,col2,col3) IS NOT NULL
Запрос 2 :
select CASE WHEN COALESCE(col1,col2,col3) IS NULL THEN 'Undefined' ELSE
COALESCE(col1,col2,col3) END from temp
Результаты :
| col1 | col2 | col3 |
|--------|--------|------|
| (null) | (null) | W |
| A | B | W |