Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 calculating salary per hour?

Author  Topic 

weitzhandler
Yak Posting Veteran

64 Posts

Posted - 2008-01-26 : 22:10:50
is there a way to create a SELECT clause which counts the accumulate hours from tw columns in same row (entering hour and leaving hour) and then calculating the total price according to a parameter?

Shimi

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-26 : 23:11:57
what datatypes are the enteringHour and leavingHour? Could get ugly if it is varchar like 9:15 AM and 2:33 PM. Assuming they are numeric it could be as simple as:
select (leavingHour-enteringHour)*@P as [TotalPrice] from ...

Be One with the Optimizer
TG
Go to Top of Page

weitzhandler
Yak Posting Veteran

64 Posts

Posted - 2008-01-27 : 08:13:48
unfortunately,now I figured that my problem is much harder:
the employee has two buttons: entering & exit.
each time the user clicks a button, a row containing his details and the time he clicked, and a varchar 'Enter' or 'Exit' in a certain column is added to the table.

so it's very complicated now.
because 1st of all I have to check if there is no two Enter or Exit entries sequentially, then if first row is exit or last row is enter, remove it from count, and 3rd, calculate what is total time span between each Enter-Exit couple, and only then I can translate the total time span to money...

it would be anyway useful for me to know what is the answer because I happen to this situation often (and I solve it programmatically which reduces the performance I'm sure).

whatever I think this time I will do it programmatically because I'm being stock with CE...

Shimi
Go to Top of Page
   

- Advertisement -