select D.Firm_ID, sum(R.Quantity) from StoreDocuments D join StoreDocuments2 R on D.ID = R.Parent_ID where D.DocumentType = '20' and R.RowType = 3 and R.StoreCard_ID = :OBJID and ((:StoreID = '0000000000') or (R.Store_ID = :StoreID)) and (D.Firm_ID in (select ID from Firms where ID = D.Firm_ID and Hidden = 'N')) group by D.Firm_ID order by 2 desc
Generated by ABRA Software a.s. 27.10.2021 16:34:11