I have three columns. each column can be null, have a telephone number starting 01 or a telephone number starting 07. I want to work out which column has an 07 number and show just that result in a single column. if there is no column starting with 07 I want to skip the record.
I have been trying this but cant get it to select column 3: -
SELECT ID_no, tel_no1, tel_no2, tel_no3,
coalesce(
CASE WHEN (tel_no1 like '01%' or tel_no1 = null) THEN tel_no2 ELSE NULL END,
CASE WHEN (tel_no2 like '01%' or tel_no2 = null) THEN tel_no3 ELSE NULL END)
from Table where ID_no = 50032