Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a transform

Status
Not open for further replies.

russgreen

Programmer
Dec 7, 2002
86
GB
I have a database that I'm trying to perform a transform query on.

I have the following query that is working OK:

Code:
TRANSFORM Sum(tblInvoices.InvoiceAmount) AS SumOfInvoiceAmount
SELECT Sum(tblInvoices.InvoiceAmount) AS TotalInvoicing
FROM tblProjects INNER JOIN tblInvoices ON tblProjects.ProjectID = tblInvoices.ProjectID
WHERE (((DatePart("yyyy",[DueDate]))=[@Year]))
GROUP BY tblInvoices.CompanyID
PIVOT Format([DueDate],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

This query simply sums monthly totals for invoices from the table tblInvoices.

Within my database I also have a table that stores project (tblProjects). Invoices in tblInvoices relate top tblProject with the field ProjectID. At times projects go on hold (tblProjects.StatusID=3).

What I want to achieve is to have a transform query thats sums the monthly invoicing totals where the tblProjects.StatusID is NOT 3. Except if an invoice has been issued (tblInvoices.Issued=True) I want to include it in the total, even if the project that it relates to is tblProjects.StatusID=3

Any help here would be greatly appreciated.

Russ
 
Something lik this ?
...
WHERE DatePart("yyyy",[DueDate])=[@Year]
AND (tblProjects.StatusID<>3 OR tblInvoices.Issued=True)
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top