N
nltoft
I would like to create a DataTable from another DataTable so that I can sum
certain fields using a GROUP BY clause. Is this possible?
For example:
Table1:
Employee, Department, Hours (these are the field names)
Emp1, Dept1, 8 (first row of data)
Emp1, Dept1, 8
Emp1, Dept2, 8
Emp1, Dept1, 8
Emp1, Dept2, 8
Emp2, etc.
I want to create a Table2 from Table1 using:
SELECT Employee, Department, SUM(Hours) as TotHrs FROM Table1
GROUP BY Employee, Department
So for Emp1, Table2 would contain two rows:
Employee, Department, TotHrs
Emp1, Dept1, 24
Emp1, Dept2, 16
If this is not possible, is there some way to achieve the same effect?
certain fields using a GROUP BY clause. Is this possible?
For example:
Table1:
Employee, Department, Hours (these are the field names)
Emp1, Dept1, 8 (first row of data)
Emp1, Dept1, 8
Emp1, Dept2, 8
Emp1, Dept1, 8
Emp1, Dept2, 8
Emp2, etc.
I want to create a Table2 from Table1 using:
SELECT Employee, Department, SUM(Hours) as TotHrs FROM Table1
GROUP BY Employee, Department
So for Emp1, Table2 would contain two rows:
Employee, Department, TotHrs
Emp1, Dept1, 24
Emp1, Dept2, 16
If this is not possible, is there some way to achieve the same effect?