jerry_gilels
asked on
Need MySQL query: translate AWK script to MySQL query...
Need a MySQL query that will produce the total so far today of telephone minutes used. Have been running awk script against flat file for years. Moved to MySQL, now need equivalent query. See the awk code below.
Would like a select statement that will round each record's seconds as the awk script provides for below.
Would like a select statement that will round each record's seconds as the awk script provides for below.
----------- AWK SCRIPT -------------
global roundrate = 6 // six-second increments
global minimum = 12 // minimum number of seconds
{
total_minutes += (round($0,roundrate,minimum)/60)
}
function round(amount,roundrate,minimum)
{
tstamt = amount * 1
if (tstamt > 0)
{
if (tstamt < minimum)
tempn = minimum
else
tempn = int((tstamt + roundrate - 1) / roundrate) * roundrate
}
else
tempn = tstamt
return tempn
}
END {
print total_minutes
}
---------------- END -----------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER