473,473 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sum of derived value?

Lokean
71 New Member
Hi foks!

I am trying to get the sum of labor per worker.

I have gotten as far as what I have below, with the start time being deducted from the end time, but now I want the total of time spent on the job within a given range of time.

Can I do it within this statement, or do I need to pass this as a function and called by another one?


SELECT WOrder.Worker AS Worker_ID, WOrder.StartDate, WOrder.Date, [LaborTab.StartTime] AS Time1, LaborTab.EndTime, ([EndTime]-[LaborTab.StartTime])*24 AS Time2, LaborTab.WorkCode, dbo_WorkOrderProd.ProdNum, LaborTab.WorkOrdID_ID, WOrder.OrgName, WOrder.WOType, Workers.LastName AS Time200, Workers.FullName
FROM DATE_RANGE, (Workers INNER JOIN (LaborTab INNER JOIN WOrder ON LaborTab.WorkOrdID_ID = WOrder.WorkOrdID_ID) ON Workers.Worker_ID = WOrder.Worker) INNER JOIN dbo_WorkOrderProd ON LaborTab.WorkOrderProd_ID = dbo_WorkOrderProd.WorkOrderProd_ID
WHERE (((WOrder.StartDate) Between [START DATE] And [END DATE]) AND ((([EndTime]-[LaborTab.StartTime])*24)<>'') AND ((LaborTab.WorkCode) Like "AP*") AND ((WOrder.OrgName) Not In ("Test1","Test2")))
ORDER BY LaborTab.WrkLabID, LaborTab.WorkCode DESC;
Apr 2 '07 #1
1 1267
iburyak
1,017 Recognized Expert Top Contributor
Assuming your calculation is correct. I don't see a data sample to make any judgment of it.

[PHP]([EndTime]-[LaborTab.StartTime])* 24[/PHP]

Try this:

[PHP]SELECT WOrder.Worker AS Worker_ID, WOrder.StartDate, WOrder.Date,
[LaborTab.StartTime] AS Time1, LaborTab.EndTime,
sum(([EndTime]-[LaborTab.StartTime])* 24) AS Time2,
LaborTab.WorkCode, dbo_WorkOrderProd.ProdNum,
LaborTab.WorkOrdID_ID, WOrder.OrgName,
WOrder.WOType, Workers.LastName AS Time200, Workers.FullName
FROM DATE_RANGE, (Workers INNER JOIN (LaborTab INNER JOIN WOrder ON LaborTab.WorkOrdID_ID = WOrder.WorkOrdID_ID) ON Workers.Worker_ID = WOrder.Worker) INNER JOIN dbo_WorkOrderProd ON LaborTab.WorkOrderProd_ID = dbo_WorkOrderProd.WorkOrderProd_ID
WHERE (((WOrder.StartDate) Between [START DATE] And [END DATE])
AND ((([EndTime]-[LaborTab.StartTime])*24)<>'')
AND ((LaborTab.WorkCode) Like "AP*")
AND ((WOrder.OrgName) Not In ("Test1","Test2")))
GROUP BY WOrder.Worker, WOrder.StartDate, WOrder.Date,
[LaborTab.StartTime], LaborTab.EndTime,
LaborTab.WorkCode, dbo_WorkOrderProd.ProdNum,
LaborTab.WorkOrdID_ID, WOrder.OrgName,
WOrder.WOType, Workers.LastName, Workers.FullName
ORDER BY LaborTab.WrkLabID, LaborTab.WorkCode DESC;[/PHP]

Good Luck.
Apr 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Christian Engström | last post by:
When i compile the program listed below with gcc version 3.3.1 (MinGW on Windows XP) I get the following result: Calling 'func(d)': 'base' copy constructor Calling 'func(*d_handle)': 'base'...
7
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
2
by: DotNetShadow | last post by:
Hi Guys, I'm trying to work out how events work in VB.NET Basically I want to create a base class that has an Event. I would like all derived classes to inherit this event. I sorta worked out...
6
by: John Glover | last post by:
I'm having a very strange problem with XML serialization. I'm writing web services which pass instances of various classes back and forth as parameters and return values of web methods. The...
9
by: Mirko Puhic | last post by:
Is there a way to properly do this? struct Derived; struct Base{ Derived der; };
8
by: Raider | last post by:
I have simple class hierarchy (without multiple inheritance): class Base {}; class Derived : public Base {}; class DeepDerived : public Derived {}; // ... a lot of types Is it ok to cast...
24
by: AtariPete | last post by:
Hey All, I have a C# question for you regarding up casting (base to derived). I was wondering about the most elegant way (readable, less code) to cast from a base type to its derived type....
15
by: Bob Johnson | last post by:
I have a base class that must have a member variable populated by, and only by, derived classes. It appears that if I declare the variable as "internal protected" then the base class *can*...
9
by: Taras_96 | last post by:
Hi everyone, I was experimenting with static_cast and reinterpret cast #include <iostream> struct A1 { int a; }; struct A2 { double d; }; struct B : public A1, A2
6
by: Christopher | last post by:
I've seen various ways of doing this, but what I want is to be able to take a base class pointer and know which derived class to cast to. For example I am going to make a base light class, that...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.