Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 GROUP BY

Author  Topic 

joshp
Starting Member

8 Posts

Posted - 2004-03-25 : 14:00:30
Please help me if you can. I have three tables:

[employeeInfo]
------------------------------------------------------------------------------------
employee_ID, employee_fname, employee_lname, employee_TitleCode, employee_Type, pay
====================================================================================
1, john, jenkins, 1, 1, 1249.95
2, bill, franks, 1, 1, 1223.92
3, darel, longs, 2, 2, 1200.95
4, mike, packard, 2, 2, 4912.18

[employee_TitleCode]
------------------------------------------------------------------------------------
employee_Title, employee_shortDesc
====================================================================================
1, manager
2, programmer

[employeeType]
-----------------------------------------------------------------
employee_Type, employee_shortDesc
=================================================================
1, exempt
2, non-exempt




== I am trying to get this output and need the T-SQL statement to do it ==
[output1]
-----------------------------------------------------------------
employee_Type, AVG salary
=================================================================
1, (Average salary of all employees in the exempt group)
2, (Average salary of all employees in the non-exempt group)

[output2]
-----------------------------------------------------------------
employee_Title, TotalPay
=================================================================
1, (total pay for all employees in the manager group)
2, (total pay for all employees in the programmer group)


I would thank anyone a million times if they could help me through this problem. I have been trying GROUP BY funtions and they do not work for me. Thanks again in advance.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-25 : 14:06:11
Output1:

SELECT Employee_Type, AVG(pay) AS AvgSalary
FROM EmployeeInfo
GROUP BY Employee_Type

Output2:

SELECT Employee_TitleCode, SUM(Pay) AS TotalPay
FROM EmployeeInfo
GROUP BY Employee_TitleCode

Tara
Go to Top of Page

joshp
Starting Member

8 Posts

Posted - 2004-03-25 : 14:13:19
Thank you Tara (1 million times)
Go to Top of Page

joshp
Starting Member

8 Posts

Posted - 2004-03-25 : 14:13:21
Thank you Tara (1 million times)
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-03-25 : 14:43:54
What's this for?
Go to Top of Page
   

- Advertisement -