rschmehl
asked on
What does this percent sign do ?
What does this SQL statement do and how does the % sign work
I am trying to get an averrage time per call and this is what I came across in the exsisting code.
,RIGHT('00'+CAST((SUM(ACD. talkTime)/ COUNT(ACD. StartDateT ime)%60) AS VARCHAR),2) AS [Avg_Talk_Time]
I am trying to get an averrage time per call and this is what I came across in the exsisting code.
,RIGHT('00'+CAST((SUM(ACD.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes the %b acts like a MOD giving the remander. I did not know it did this with TIME values but i guess it does. Thanks
Thanks for the grade. Good luck with your project. -Jim
>> did not know it did this with TIME values
it isn't dealing with time units directly, in this case it is: sum()/count() then modulus of 60
SUM(ACD.talkTime)/COUNT(AC D.StartDat eTime) % 60
tip: modulus of 7 when working with days of week is excellent, e.g.
SELECT datediff(DAY,0,getdate()) % 7 -- 0 is Monday (regardless of sqlserver settings)
it isn't dealing with time units directly, in this case it is: sum()/count() then modulus of 60
SUM(ACD.talkTime)/COUNT(AC
tip: modulus of 7 when working with days of week is excellent, e.g.
SELECT datediff(DAY,0,getdate()) % 7 -- 0 is Monday (regardless of sqlserver settings)
Also looks like the parentheses marks are not correct, perhaps this should be..
Open in new window