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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combined Query

Status
Not open for further replies.

seke

Programmer
Nov 30, 2002
14
PT
Table: Account
Fields: CompanyName, InvoiceDate, InvoiceAmount, Status

Status will = 3 ie Invoiced

I need a query that will produce the following from the above data in colums.

col 1. Company name
col 2. Toatal amount owed by each company
col 3. Toatal amount owed from a date + 30 days
col 4. Toatal amount owed from a date + 60 days
col 5. Toatal amount owed from a date + 90 days
col 6. Toatal amount owed from a date + 120 days

I can make a query that will do each, but I need one query which does all the above.

Im old, I'm tired and my brain hurts Helppppppppppppp!

S.eke


 


Hi,
Code:
Select CompanyName
, Sum(InvoiceAmount)
, sum(iif(InvoiceDate Between [a date] and [a date]+30,InvoiceAmount,0))
, sum(iif(InvoiceDate Between [a date] and [a date]+60,InvoiceAmount,0))
, sum(iif(InvoiceDate Between [a date] and [a date]+90,InvoiceAmount,0))
, sum(iif(InvoiceDate Between [a date] and [a date]+120,InvoiceAmount,0))
From Account
Where Status='3'
Group By CompanyName


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Skip

Thanks

Working as wished. Now I can sleep.

Thanks again

S.Eke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top