Hello.
It is possible to obtain your results without temporary tables, but
with user variables. For a pity you should execute three queries.
With first query you're getting the Sum:
select @all_sum:= count( employee_id) from table_employee
where employee_hire_date between
Without knowing more of your requirements, I find seeing the grand total and
overall average repeated in every row strange from a usability perspective.
Do you really need that, or were you just hoping to get that information out
of your query?
I'd suggest something like:
SET @sum=0, @m=0;
Hello MySQL users,
Currently, I use MySQL 4.0.22 and I can do a straightforward count of
employees hired for each month.
select employee_hire_date, count(employee_id)
from table_employee
where employee_hire_date between 2005-01-01 and 2005-4-30
group by month(employee_hire_date)
Date |