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.
| Author |
Topic |
|
Crima
Starting Member
17 Posts |
Posted - 2012-10-18 : 17:49:07
|
| I'm trying to figure out this problemWrite a SELECT statement that returns four columns:VendorName From the Vendors tableInvoiceNumber From the Invoices tableInvoiceDate From the Invoices tableBalance InvoiceTotal minus the sum of PaymentTotal and CreditTotalThe 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, InvoicesWHERE ORDER BY VendorNameI tried WHERE (InvoiceTotal - (PaymentTotal + CreditTotal) As BalanceBut 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 BalanceFROM Vendors INNER JOIN InvoicesON Vendors.VendorID = Invoices.VendorIDWHEREORDER BY VendorName[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Crima
Starting Member
17 Posts |
Posted - 2012-10-18 : 22:07:30
|
| Thank you Khtan, wrong line ^_^A witty student |
 |
|
|
|
|
|