Re: Help With SELECT Statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



SELECT ContactName, SUM(SumAmount)
FROM
(
SELECT tblContacts.ContactName, Sum(tblInvoices.InvoiceAmount) AS
SumAmount
FROM tblContacts RIGHT JOIN tblInvoices ON tblContacts.ContactID =
tblInvoices.ContactID
GROUP BY tblContacts.ContactName
UNION ALL SELECT tblContacts.ContactName,
Sum(tblPayments.PaymentAmount) AS SumAmount
FROM tblContacts RIGHT JOIN tblPayments ON tblContacts.ContactID =
tblPayments.ContactID
GROUP BY tblContacts.ContactName
)
GROUP BY ContactName

HTH, jens Suessmeyer.

.



Relevant Pages

  • Re: Help With SELECT Statement
    ... > SELECT ContactName, SUM ... > FROM tblContacts RIGHT JOIN tblInvoices ON tblContacts.ContactID = ... > SumAS SumAmount ...
    (microsoft.public.sqlserver)
  • Re: concatenating fields in an SQL query
    ... > get a nieuw field ContactName to select in dropdownbox. ... > If one of the 3 fields is empty i get an empty ContactName string back. ... > tblContacts.*, ...
    (borland.public.delphi.database.ado)
  • concatenating fields in an SQL query
    ... I'm trying to concatenate 3 fields: FirstName + MiddleName + LastName to get ... If one of the 3 fields is empty i get an empty ContactName string back. ... FROM tblContacts ... MiddleName, Text 10, Required = No, Allow Zero Length = Yes ...
    (borland.public.delphi.database.ado)
  • Re: How do I find duplicates in Access 2002 without the install cd-rom
    ... SELECT ContactName, Countas NumOf ... FROM tblContacts ... MS Access MVP ...
    (microsoft.public.access.queries)