sqlcounter noresetcounter {
                counter-name = Max-All-Session-Time
                check-name = Max-All-Session
                sqlmod-inst = sql
                key = User-Name
                reset = never
 
                query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}'"
 
        }
 
 
sqlcounter dailycounter {
                driver = "rlm_sqlcounter"
                counter-name = Daily-Session-Time
                check-name = Max-Daily-Session
                sqlmod-inst = sqlcca3
                key = User-Name
                reset = daily
                                                                                                                             
                query = "SELECT SUM(AcctSessionTime - GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
                                                                                                                             
        }
                                                                                                                             
sqlcounter monthlycounter {
                counter-name = Monthly-Session-Time
                check-name = Max-Monthly-Session
                sqlmod-inst = sqlcca3
                key = User-Name
                reset = monthly
                                                                                                                             
                #query = "SELECT SUM(AcctSessionTime - GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
                query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
                                                                                                                             
        }
