USE AP DECLARE @BalanceDue money SET @BalanceDue = (SELECT SUM(InvoiceTotal-PaymentTotal-CreditTotal) FROM Invoices) IF @BalanceDue > 10000 (SELECT VendorName, InvoiceNumber, InvoiceDueDate, InvoiceTotal-PaymentTotal-CreditTotal AS BalanceDue FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal-PaymentTotal-CreditTotal > 0 ORDER BY InvoiceDueDate DESC) ELSE PRINT 'Balance due is less than $10000'
Page 1 of 1
2 Replies - 1004 Views - Last Post: 02 November 2012 - 09:50 AM
ORDER BY clause not working
Posted 02 November 2012 - 09:34 AM
Hi all! I am working on a homework assignment. I have the majority of it done, but my ORDER BY clause is throwing an error. If I take the clause out, it runs fine, and I can't figure out why. I'm thinking there is a rule I am forgetting, but I have looked through my book and can't find anything.
Replies To: ORDER BY clause not working
Re: ORDER BY clause not working
Posted 02 November 2012 - 09:50 AM
Is this MSSQL or MYSQL? If the former then double check your if statements.. instead of ( and ) it is BEGIN and END.
It's MSSQL.. Thanks for the link Modi, works great now!
This post has been edited by synlight: 02 November 2012 - 09:52 AM
Page 1 of 1