DECLARE @Blocked DECIMAL(18,2) SELECT @Blocked = SUM(b.Amount) FROM dbo.Bills b LEFT JOIN dbo.Invoices inv ON b.Id = inv.BillId WHERE inv.Id IS NULL