How can I write an If else Ladder in MS Access SQL query and not in the code using Recordset.
I have the conditions like this:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE SpecialityCode = '130'
AND SpecialistCode = 'C4535421' AND WeekNum = 1
It will give any value and if not, I want to run this query:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE SpecialityCode = '130'
AND SpecialistCode = 'C4535421' AND (WeekNum is Null or WeekNum = '')
It will give any value and if not, I want to run this query:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE SpecialityCode = '130'
AND (SpecialistCode is null or SpecialistCode ='') AND WeekNum = 1
It will give any value and if not, I want to run this query:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE SpecialityCode = '130'
AND (SpecialistCode is null or SpecialistCode ='') AND (WeekNum is Null or WeekNum = '')
It will give any value and if not, I want to run this query:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE (SpecialityCode is null
or SpecialityCode ='') AND (SpecialistCode is null or SpecialistCode ='') AND WeekNum = 1
It will give any value and if not, I want to run this query:
SELECT min(ThresholdValue) FROM tbl_Threshold WHERE (SpecialityCode is null
or SpecialityCode ='') AND (SpecialistCode is null or SpecialistCode ='')
AND (WeekNum is Null or WeekNum = '')
Basically, I am giving 3 conditions in the query, and if no record found for that condition, then I am replacing a condition with blank value or null step by step. Currently I am doing it using recordsets, means checking count of a recordset, if 0 then filling recordset with next condition and so on. But this approach is taking so much time, because this itself is being done in a loop over 100 around records. So any other way I could do this,may be in a single query?