Assuming a wagetable:
name lowhours highhours wage
Default 0.0 40.0 100
Default 40.0 50.0 150
Default 50.0 70.5 154
Default 70.5 100.0 200
Brian 0.0 40.0 200
Brian 40.0 50.0 250
Brian 50.0 60.0 275
Brian 60.0 70.0 300
Brian 70.0 80.0 325
Brian 80.0 9999.0 350
Chad 0.0 40.0 130
Chad 40.0 9999.0 170
I am currently using this code (AutoIT scripting:
func getCurrentWage($Employee, $Hour_number)
Dim $row
Local $Wage = 0
Local $Found = "found"
_SQLite_QuerySingleRow(-1, "SELECT wage FROM wagetable WHERE name LIKE " & _SQLite_Escape($Employee) & " AND " & _SQLite_Escape($Hour_number) & " BETWEEN lowhours AND highhours;", $row)
if @error then
_SQLite_QuerySingleRow(-1, "SELECT wage FROM wagetable WHERE name LIKE 'Default' AND " & _SQLite_Escape($Hour_number) & " BETWEEN lowhours AND highhours;", $row)
$Found = "not found"
endif
If ($row[0] == "") Then Msgbox(0,0,"Error getCurrentWage")
$Wage = $row[0]
Debug("Wage='" & $Wage & "' because " &$Employee&" was "& $Found& " -- and Hours Elapsed is " & $Hour_number, true)
return $Wage
EndFunc
So those 2 queries are perfect if the Hour_number is inbetween a low hour or a high hours. I need some sort of query where it will basically do something like:
SELECT wage from wagetable WHERE name LIKE $Employee AND max(highhours)
and then just repeat it for 'Default' is the employee is not found.
Extra: Is it possible to try the 'Default' if $Employee is not found with just 1 query?