select
case
when :ARKind = 0 then count(A.AssetLocation_ID)
when :ARKind = 1 then count(A.Responsible_ID)
when :ARKind = 2 then count(A.EvidenceDivision_ID)
when :ARKind = 3 then count(A.ExpensesDivision_ID)
end as ID
from AssetInvListRestrictions A
join AssetInvLists B on B.ID = A.Parent_ID
where
(B.Parent_ID = :OBJID) and
((A.IncludedAssetTypes = 0) or (A.IncludedAssetTypes = :AInclAssetType)) and
(
((:ARKind = 0) and (A.AssetLocation_ID = :AOID)) or
((:ARKind = 1) and (A.Responsible_ID = :AOID)) or
((:ARKind = 2) and (A.EvidenceDivision_ID = :AOID)) or
((:ARKind = 3) and (A.ExpensesDivision_ID = :AOID))
)
Generated by ABRA Software a.s. 27.10.2021 16:34:24