SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple Math help!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Crima
Starting Member

USA
17 Posts

Posted - 10/18/2012 :  17:49:07  Show Profile  Reply with Quote
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)

Singapore
17441 Posts

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



KH
Time is always against us


Edited by - khtan on 10/18/2012 21:01:10
Go to Top of Page

Crima
Starting Member

USA
17 Posts

Posted - 10/18/2012 :  22:07:30  Show Profile  Reply with Quote
Thank you Khtan, wrong line ^_^

A witty student
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000