Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple Math help!

Author  Topic 

Crima
Starting Member

17 Posts

Posted - 2012-10-18 : 17:49:07
I'm trying to figure out this problem

Write a SELECT statement that returns four columns:
VendorName From the Vendors table
InvoiceNumber From the Invoices table
InvoiceDate From the Invoices table
Balance InvoiceTotal minus the sum of PaymentTotal and CreditTotal
The result set should have one row for each invoice with a non-zero balance. Sort the result set by VendorName in ascending order.

so far I have,

SELECT VendorName, InvoiceNumber, InvoiceDate
FROM Vendors, Invoices
WHERE
ORDER BY VendorName

I tried WHERE (InvoiceTotal - (PaymentTotal + CreditTotal) As Balance
But it didn't work, any help?


A witty student

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-10-18 : 21:00:44
[code]SELECT VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal - (PaymentTotal + CreditTotal) As Balance
FROM Vendors INNER JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID
WHERE
ORDER BY VendorName[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Crima
Starting Member

17 Posts

Posted - 2012-10-18 : 22:07:30
Thank you Khtan, wrong line ^_^

A witty student
Go to Top of Page
   

- Advertisement -