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 |
jamesingamells
Starting Member
11 Posts |
Posted - 2013-10-22 : 05:20:27
|
Hi,I am having an issue with an averageg i am trying to calculate. Here is the query. The results i am getting back are 27.00, 12.00 etc, when they should be 27.38, 12.67 etc.Any advice?SELECT Week,Hospital, CAST( avg(Length_Of_Stay) AS DECIMAL(10,2)) as Average_LoS FROM tableGROUP BY Week,Hospital |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-10-22 : 05:58:34
|
SELECT Week,Hospital, CAST( avg(Length_Of_Stay*1.0) AS DECIMAL(10,2)) as Average_LoSMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-22 : 07:49:54
|
should be this i guessSELECT Week,Hospital, avg(CAST(Length_Of_Stay AS DECIMAL(10,2))) as Average_LoSFROM tableGROUP BY Week,Hospital ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|