sql - Group by month and add year and employee -
i have simple table every sale made in few past years. find out maximum sale per month , made , in year , month.
table has following columns:
id, date, amount, employeeid
i group data year(date), month(date), employeeid , use sum(amount) find sale of each employee in each month. group further month(date) , use max on sum(amount) column find maximum sale per month. easy.
after find out when (date) , (employeeid) made particular sale.
group data year(date), month(date), employeeid , use sum(amount) find sale of each employee in each month order sum(amount) desc. highest sellers @ top of results.
Comments
Post a Comment