SELECT CASE “欄位名"
WHEN “條件1″ THEN “結果1″
WHEN “條件2″ THEN “結果2″
….
[ELSE "結果N"]
END
謝謝大大提供方法,但是一直無法成功,謝謝!
試試看:
Select convert(varchar,date,111)+' '+datename(weekday,date) as date,
'employeeID'=case
where employeeID NOT IN ('SP99306','Fu-Yu01','Fu-Yu02') and commuting_time=00 then '條件一'
where employeeID NOT IN ('SP99306','Fu-Yu01','Fu-Yu02') and commuting_time=01 then '條件二'
else '沒有符合條件'
end,
Dept,NameID,convert(varchar,date,108) as work_online
最後少了
From myabsent