Sys(3009,70) Select Inout.cid, InOut.tdate, InOut.iInOrOut...; Sum(tToSec(InOut.tdate)*iif(InOut.iInOrOut=1,1,0)) As Sum_In, ; Sum(tToSec(InOut.tdate)*iif(InOut.iInOrOut#1,1,0)) As Sum_Out, ; ... Where InOut.tdate>=m.tStart AND ; InOut.tdate<=m.tEnd ; Group By InOut.tdate, InOut.cid .Now I have to have a field there to to show how many days employers has been in work between m.tStart and m.tEnd. Using plain Count may not be the option (?) because he/she can be logged in/out multiple time (one log is one record) per day.