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 |
|
hiklior
Starting Member
2 Posts |
Posted - 2008-05-28 : 17:03:30
|
| Problemfldyear fldascending flddecending2007 20 232006 21 142007 41 122007 12 5how do i find the average of fld ascending and descending where year=2007Your help will be appreciated |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-28 : 17:14:28
|
| Use the AVG function.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
hiklior
Starting Member
2 Posts |
Posted - 2008-05-28 : 17:14:34
|
| i also want it to be grouped by year ( which has to be distinct) . i appreciate your help |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-28 : 17:27:09
|
| Please show us what you have tried.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
LTack
Posting Yak Master
193 Posts |
Posted - 2008-05-28 : 17:29:48
|
| SELECT avg(fldascending), avg(flddescending) FROM _table_ WHERE year=2007 GROUP BY year;^^ I'm pretty new to SQL, so not sure if I'm right on this or not. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-28 : 17:31:41
|
| That looks fine. Is it returning an error or not returning the correct results?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
LTack
Posting Yak Master
193 Posts |
Posted - 2008-05-28 : 17:39:16
|
| *twiddles thumbs*Why do I stalk forums, why do I stalk forums, why do I--hi.(Thanks, tkizer...I was nervous attempting to post a solution, lol) |
 |
|
|
|
|
|