Please help me with below query , I want to check if string is starts with 'G' or 'F' in where condition along with existing condition. here is the query
first query :-
SELECT Top 1 LC_ID, ISNULL(LC_UD, 0) as Record
WHERE LC_ID = 'F01'
F01 | 1 ( if available) else no record will be return.
IF LC_ID starts with 'F%' or 'G%'
F04 | 1
You want to prioritize the values being returned. Because you want only one, you can do this with
SELECT Top 1 LC_ID, COALESCE(LC_UD, 0) as Record FROM CONTRACT WHERE LC_ID LIKE '[FG]%' ORDER BY (CASE WHEN LC_ID = 'F01' THEN 1 ELSE 2 END);
Note: This assumes you are using SQL Server (based on the syntax).