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.
| 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.952, bill, franks, 1, 1, 1223.923, darel, longs, 2, 2, 1200.954, mike, packard, 2, 2, 4912.18[employee_TitleCode]------------------------------------------------------------------------------------employee_Title, employee_shortDesc====================================================================================1, manager2, programmer[employeeType]-----------------------------------------------------------------employee_Type, employee_shortDesc=================================================================1, exempt2, 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 AvgSalaryFROM EmployeeInfoGROUP BY Employee_TypeOutput2:SELECT Employee_TitleCode, SUM(Pay) AS TotalPayFROM EmployeeInfoGROUP BY Employee_TitleCodeTara |
 |
|
|
joshp
Starting Member
8 Posts |
Posted - 2004-03-25 : 14:13:19
|
| Thank you Tara (1 million times) |
 |
|
|
joshp
Starting Member
8 Posts |
Posted - 2004-03-25 : 14:13:21
|
| Thank you Tara (1 million times) |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-03-25 : 14:43:54
|
| What's this for? |
 |
|
|
|
|
|
|
|