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

Calculating time

Status
Not open for further replies.

Spikemannen

Instructor
Feb 22, 2005
58
0
0
SE
Hi.

I have three tables.
tblCompany
CompanyID (count)
CompanyName (txt)

tblInvoice
ID (count)
CompanyID (related to tblCompany)
InvoiceDate (date)
InvoiceNo (txt)
TimeFrom (date)
Time (number)

tblSupport
ArrendID (count)
CompanyID (related to tblCompany)
Arrive (date)
Area (txt)
Description (pm)
Finished (yes/no)
FinishDate (date)
EstimatedTime (number)

Now I want tblInvoice.Time.Value to show the sum for all tblSupport.EstimatedTime.Value where tblSupport.CompanyID.Value is the same as in tblInvoice.CompanyID.Value and when the finished date is after tblInvoice.TimeFrom.Value.

Is there anyone out there that has an idea how to solve this?

Best Regardz,

Spikemannen
 
Something like this ?
SELECT I.ID, I.CompanyID, I.InvoiceDate, I.InvoiceNo, I.TimeFrom, Sum(S.EstimatedTime) AS TotalTime
FROM tblInvoice AS I INNER JOIN tblSupport AS S ON I.CompanyID = S.CompanyID
WHERE S.FinishDate > I.TimeFrom
GROUP BY I.ID, I.CompanyID, I.InvoiceDate, I.InvoiceNo, I.TimeFrom;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

I had almost the same solution. LOL - I posted on his other post. Funny that we used the same alias'.

(I broke it into company billing, you broke it down to individual bill)

Randall Vollen
National City Bank Corp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top