i have simple query want search value in column, , if no match found want discard condition , select random value column.
i have tried achieve using or condition, using case, no avail
select top 10 * tblrfcworkload (f1 ='mbb' or f1 = f1) in above query want result table have rows 'mbb', if 'mbb' not found give value instead of mbb. instead returns 2 rows mbb though there 10 matching rows
select top 10 * tblrfcworkload 1 = case when f1 = 'mbb' 1 else 1 end this query returns same result 1st query
if change
select top 10 * tblrfcworkload 1 = case when f1 = 'mbb' 1 else 0 end then rows having mbb value.
need similar thing between clause... search 1 range if no results found search second range... how do that???
i think want this:
select top 10 * tblrfcworkload order (case when f1 = 'mbb' 1 else 2 end); this prioritizes rows want, fetching top 10 'mbb', if available.
Comments
Post a Comment