sql - Check string starts with specific letter -


please me below query , want check if string starts 'g' or 'f' in condition along existing condition. here query

first query :-

select top 1 lc_id, isnull(lc_ud, 0) record  contract lc_id = 'f01' 

output

f01 | 1 ( if available) else no record return. 

second query:

if lc_id starts 'f%' or 'g%' 

how can integrate both query 1 if there no record available 'f01' value, check if lc_id starts f & g return output

f04 | 1 

else no record return.

you want prioritize values being returned. because want one, can order by:

select top 1 lc_id, coalesce(lc_ud, 0) record  contract lc_id '[fg]%' order (case when lc_id = 'f01' 1 else 2 end); 

note: assumes using sql server (based on syntax).


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -