select
CASE WHEN prescription_audit.operation_type = 'P' AND pharmacy_mstr.name like '%mail order%' THEN '2' -- for mail order
WHEN prescription_audit.operation_type = 'P' and pharmacy_mstr.name not like '%mail order%' THEN '1' -- for pharmacy
WHEN prescription_audit.operation_type = 'E' THEN '0' -- for erx
WHEN prescription_audit.operation_type = 'F' THEN '1' -- for fax
ELSE '0'
END AS Patient_Eligibility
from prescription_audit, pharmacy_mstr
where etc etc