以前使用過Switch方式處理資料,去年底以來一直使用Power Query,對於SQL的語法有點生疏,還好還是試出來了。
select *,int((離職日-到職日)/365) as 年資,
switch(
[CF_DEPT_CABBR] like "%AC%","AC課"
,[CF_DEPT_CABBR] like "%RAD%","RAD課"
,[CF_DEPT_CABBR] like "%工程%","工程課"
,[CF_DEPT_CABBR] like "%線外%","線外加工課"
,[CF_DEPT_CABBR] like "%資材%","資材部"
,[CF_DEPT_CABBR] like "%擠%","擠型課"
,[CF_DEPT_CABBR] like "%生技%","生技課"
,[CF_DEPT_CABBR] like "%會計%","財務會計處"
,[CF_DEPT_CABBR] like "%財務%","財務會計處"
,[CF_DEPT_CABBR] like "%管理課%","管理課"
,[CF_DEPT_CABBR] like "%物流課%","物流課"
,true,[CF_DEPT_CABBR]) as 部門 from ['離職名單2020-2021$'] where 到職日 is not null
沒有留言:
張貼留言