>I have a file with a large number of employees in different departments, with the department numbers recurring throught the data
>
>I need a summary report by dept which lists total number of employees and total number of hours (another field on every record). I could write a routine to do it but I know_ there has to be a sql statement. Any ideas?
>
>TIA
>CG
How about:
select Department, count(*) as NumEmployees, sum(hours) as TotalHours;
from MyTable;
group by Department;
order by TotalHours descending;
into cursor Summary
I am assuming you have one record per employee.
GROUP BY will create a single summary record for each department.
HTH, Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)