sql server - How to select value from second column if first column is blank/null in SQL (MS SQL)? -
can me build sql query if column1 null/blank should value column2, if column2 blank/null should value column3.
below table using
price1 price2 price3 120 140 160
the output looking is
price 120 140 160
i have tried
select price1 price price1 not null union select price2 price price1 null union select price3 id price2 null select coalesce (price1,price2,price3) select isnull(price1,isnull(price2,price3)) select case when price1 not null price1 when price1 null price2 when price2 null price3 end price id
none of above syntax gets data i'm looking for. please help
if think have empty strings can try :
select case when coalesce(price1, '') <> '' price1 when coalesce(price2, '') <> '' price2 when coalesce(price3, '') <> '' price3 end price
Comments
Post a Comment