mysql - sql query - calculating commission over 12 months -
I am trying to write a question of how much commission my client earns in one month
< Pre> SELECT (rate * SUM (duration) / 180) Teacher, person, as a commission by WHERE person.id = teacher.person_id and lesson.teacher = person.id and MONTH (start_time) = month ( NOW ()) GROUP BY person.id This is fine to work this month, but how can I do this to give results for the last 12 months?
use GROUP BY person.id, MONTH (start_time) and last and in WHERE in MONTH (NOW ()) - MONTH (start_time) & lt; = 12 .
Comments
Post a Comment