2021-01-26

[AF] 查詢流程分類SQL

SELECT AMC.SiblingOrder,M.SiblingOrder,
       AMC.Name 流程分類名稱,
       CASE 
         WHEN SUBSTRING(ISNULL(Pro.ProID,AP.FreID),1,3) = 'PRO' THEN '流程'
         WHEN SUBSTRING(ISNULL(Pro.ProID,AP.FreID),1,3) = 'FAP' THEN '應用'
       END 類別,
       ISNULL(Pro.ProID,AP.FreID) 流程或表單編號, 
       ISNULL(Pro.Name,AP.Name) 流程或表單名稱
FROM AF_ProcessMap M
LEFT JOIN Pro_GenInf Pro ON M.ID = Pro.ProID
LEFT JOIN Freqap AP ON M.Id = AP.FreID
LEFT JOIN AF_ProcessMapCategory AMC ON M.ParentId = AMC.Id
where 1=1
–AND AMC.Name = 'XIN'
ORDER BY CAST(AMC.SiblingOrder AS INT) ASC,CAST(M.SiblingOrder AS INT) ASC

沒有留言:

張貼留言