條件句從句我在存儲過程中下面的查詢(SQL服務器):凡在存儲過程
SELECT
ea.attendanceid,
ea.employeeid,
FROM employee_attendance ea
WHERE
ea.masterentity = @masterentity
AND ea.employeeid = @employeeid
-- here I need to know what value @type is and then create my conditionals
AND (ISNULL(@type,'') = '' OR
.......
我的參數@type已經diferent字符串值:
- IL =內部午餐
- EL =外部午餐
- L =所有午餐
- N =僅正常
- R =貝斯
,並根據該值,我要過濾的列:
If `@type='IL'` then I have to filter: `AND ea.lunchtype = 'C'`
If `@type='EL'` then I have to filter: `AND ea.lunchtype = 'CI'`
If `@type='L'` then I have to filter: `AND ea.islunch = 1`
If `@type='N'` then I have to filter: `AND ea.islunch = 0`
If `@type='R'` then I have to filter: `AND (ea.ismanual = 1 AND ea.lunchtype = 'K')`
上的任何線索如何做到這一點?