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)
 sql average results round down

Author  Topic 

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-02 : 12:42:21
Afternoon,

I know there is a way to make this work but I can't seem to hit on the right combination. I need it to NOT round down or up for that matter. For example in one result set the answer I should be getting is "1990.37931" using this syntax:
CAST(Avg(MODELYEAR) AS decimal(10,5)) AS AvgOfMODELYEAR 
I get 1990.00000.

Any nudge in the right direction would be great

Thanks

Laura

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-02 : 12:44:29
try
Avg(CAST(MODELYEAR AS decimal(10,5))) AS AvgOfMODELYEAR

Go with the flow & have fun! Else fight the flow
Go to Top of Page

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-02 : 12:51:36
Are you kidding? I've been banging my head against the wall for one little set of parentheses?! Yikes!!

Thank you so much. I knew someone here would know.

Thanks again.

Laura
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-02 : 13:30:04
a thing to remember... always cast the value directly and not the aggregated value.

Have a nice day.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-08-02 : 13:58:43
Evening lauramayer,

You need a different set of parentheses?

'Cor blast, I wish I'd known, we charge extra for them!

Kristen
Go to Top of Page

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-03 : 07:46:20
Yes it's the little things....
Go to Top of Page
   

- Advertisement -