I have a database table like this:
wagetable
name lowhours highhours wage
Default 0 40 10
Default 40 9999 15
Brian 0 40 15
Brian 40 50 20
Brian 50 9999 22
Chad 0 40 13
Chad 40 9999 17
If 'Brian' worked 43.5151587 hours, I want it to figure out that he made (40*15)+(3.5151587*20) = 670.303174.
This is a SQLite database, so I know I will use:
SELECT wage FROM wagetable WHERE name LIKE 'Brian' AND 'HourNum' BETWEEN lowhours AND highhours;
With a combination of floor and %... I am just not putting the logic together in my head.
Please note answers in C# and PHP accepted, as I can convert the logic to what I need. I am looking for pseudo code but will accept drawn out answers
Edit: please note...The hours worked will never be an exact integer, why I let overlapping happen.
Edit2:
I want to take an employees total hours worked (example: 43.5151587) and then realize that the first 40 hours, he was making standard pay @ $15 an hour. so (40*15)...Then he worked 3.5151587 hours of overtime @ $20 an hour. so (40*15) add to it (3.5151587*20)...The total amount earned was 670.303174