Advertisement

06.08.2008 at 03:37PM PDT, ID: 23467694
[x]
Attachment Details

SQL 2000 Query Statement for two tables in one call

Asked by DaveRowland in SQL Server 2005

Tags: MSSQL2000, Firefox

By calling per customer (returns a line per customer) I wish to get the rows to show the Sum(BalanceRemaining), so if there is more then one invoice then it sums it up but doesn't return multiple invoices, I need it to return the list of customers.

So, CustomerID is stored in both tables to link up, many invoice to one customer rule.

If IsPaid = 0 and DueDate is in the future then return invoice but ideally I need the Sum of all the invoices returned as "BalanceRemaining" for that customer, as a customer list.




Start Free Trial
1:
2:
3:
4:
5:
SELECT     sos_customerlist.CustomerID, sos_customerlist.CompanyName, sos_invoices.BalanceRemaining, sos_invoices.AppliedAmount, 
                      sos_invoices.DueDate, sos_invoices.IsPaid
FROM         sos_customerlist INNER JOIN
                      sos_invoices ON sos_customerlist.CustomerID = sos_invoices.CustomerID
WHERE     (sos_invoices.IsPaid = 0) AND (sos_invoices.DueDate >= { fn NOW() })
[+][-]06.08.2008 at 04:40PM PDT, ID: 21740040

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: MSSQL2000, Firefox
Sign Up Now!
Solution Provided By: simonet
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628