Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Declares Variable Total Outstanding as money
- DECLARE @TotalOutstanding money;
- --Initilizes the Total Outstanding
- SELECT @TotalOutstanding = SUM(InvoiceTotal - CreditTotal - PaymentTotal)
- FROM Invoices
- WHERE InvoiceTotal - CreditTotal - PaymentTotal > 0;
- IF @TotalOutstanding > 10000
- SELECT VendorName, InvoiceNumber, InvoiceDueDate,
- InvoiceTotal - CreditTotal - PaymentTotal AS Balance
- FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
- WHERE InvoiceTotal - CreditTotal - PaymentTotal > 0
- ORDER BY InvoiceDueDate;
- ELSE
- PRINT 'Balance due is less than $10,000.00.';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement