Below is an example of a
SELECT statement. I have a variable
@total that is set to
0, which works fine if I am doing a
WHERE clause but I need the final total for each agent. Currently how this works is that each agent's records display and their total at the end. My question is how can I reset the variable when the
agentID changes to the next agent and only display the final count.
select agentID, points, @total:= @total + points AS Total, comment from attendance, (select @total:= 0) v group by agentID, incurredDate
This is what I am trying to achieve.
======================= agentID | total ======================= brwilson | 2 vimunson | 5