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'
ORDER BY clause not working
Page 1 of 12 Replies - 577 Views - Last Post: 02 November 2012 - 09:50 AM
#1
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
#2
Re: ORDER BY clause not working
Posted 02 November 2012 - 09:41 AM
Is this MSSQL or MYSQL? If the former then double check your if statements.. instead of ( and ) it is BEGIN and END.
http://msdn.microsof...7(SQL.105).aspx
http://msdn.microsof...7(SQL.105).aspx
#3
Re: ORDER BY clause not working
Posted 02 November 2012 - 09:50 AM
modi123_1, on 02 November 2012 - 11:41 AM, said:
Is this MSSQL or MYSQL? If the former then double check your if statements.. instead of ( and ) it is BEGIN and END.
http://msdn.microsof...7(SQL.105).aspx
http://msdn.microsof...7(SQL.105).aspx
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
|
|

New Topic/Question
Reply




MultiQuote







|