Before inserting the new row, you must match the last inserted row with the current day. And if it is changing reset the counter back to 1.
Algorithm can be something like
Code:
SELECT day,counter FROM last inserted row if (cur_day==1 AND cur_day<>day) new_counter = 1 else new_counter=counter+1
Leave a comment: