select SDS.anPermissionDelete, A.acKey from the_order A
join the_setsubj SS on A.acDept = SS.acSubject
INNER JOIN [dbo].[tPA_User] SSC ON SSC.acUserId = ORIGINAL_LOGIN()
join tHE_SetSubjDepartmentUserSecurity SDS on SS.anQId = SDS.anSubjectId AND SDS.anUserId = SSC.anUserID 