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
 SQL Server Development (2000)
 AVG function

Author  Topic 

dinzg
Starting Member

6 Posts

Posted - 2005-02-15 : 03:12:25

When I use AVG function in query I get result like this:

24,833333

Is there any way to get result like: 24 without 833333?

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-02-15 : 03:25:03
Is the comma a typo - should it be 24.833333

SELECT CONVERT(int,AVG(24.833333))

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2005-02-15 : 03:46:49
You can also use

SELECT FLOOR(24.833333)

or if you want to round you can use

SELECT ROUND(24.833333, 0) which would give 25.000000

or if you want to always round up you can use
SELECT CEILING(24.833333) which would give 25

see BOL for more details, especially if the average can be negative and you're using FLOOR or CEILING


steve

And how is education supposed to make me feel smarter? Besides, every time I learn something new, it pushes some old stuff out of my brain.
Go to Top of Page

dinzg
Starting Member

6 Posts

Posted - 2005-02-15 : 06:03:01
I used this one SELECT ROUND(24.833333, 0)

thanks
Go to Top of Page
   

- Advertisement -