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 |
|
obiwaugh
Starting Member
27 Posts |
Posted - 2004-06-28 : 01:00:16
|
| How does one go about calculating the mean value of a field in a table. For example, I'd like to calculate the median ANNUAL_RT for employees in department 1400.EMPLID,DEPTID,ANNUAL_RT100,1400,45000101,1400,50000102,1400,70000103,1400,75000 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-06-28 : 04:31:45
|
| i believe this gives the median value select sum(ANNUAL_RT) / count(ANNUAL_RT) from Table1Go with the flow & have fun! Else fight the flow :) |
 |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2004-06-28 : 05:43:11
|
| Do you want the MEAN or the MEDIAN?If you want the mean then the AVG function should produce equivalent results to SUM/COUNT i.e. SELECT AVG(ANNUAL_RT) FROM Employees WHERE DEPTID = 1400.If you want the median, there's a very elegant solution from jsmith8858 elsewhere on this forum: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=16257Mark |
 |
|
|
|
|
|