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 |
mosiki
Starting Member
12 Posts |
Posted - 2013-06-24 : 11:49:40
|
HiHow can I get the below query to return the result to 2 decimal places?(SUM(Soccer_Base.dbo.Results.AwayFT) + SUM(Soccer_Base.dbo.Results.HomeFT)) / COUNT(Soccer_Base.dbo.Results.AwayTeam) AS GPG ThanksMosiki |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-06-24 : 11:53:41
|
[code]convert(numeric(19,2),(SUM(Soccer_Base.dbo.Results.AwayFT) + SUM(Soccer_Base.dbo.Results.HomeFT)) / COUNT(Soccer_Base.dbo.Results.AwayTeam))[/code]CheersMIK |
|
|
mmkrishna1919
Yak Posting Veteran
95 Posts |
Posted - 2013-06-25 : 00:56:32
|
You can also use ROUND function..ROUND((SUM(Soccer_Base.dbo.Results.AwayFT) + SUM(Soccer_Base.dbo.Results.HomeFT)) / COUNT(Soccer_Base.dbo.Results.AwayTeam) ,2)AS GPGThanks..M.MURALI kRISHNA |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-25 : 01:03:58
|
quote: Originally posted by mmkrishna1919 You can also use ROUND function..ROUND((SUM(Soccer_Base.dbo.Results.AwayFT) + SUM(Soccer_Base.dbo.Results.HomeFT)) / COUNT(Soccer_Base.dbo.Results.AwayTeam) ,2)AS GPGThanks..M.MURALI kRISHNA
you'll get the value rounded to 2 decimal places but result may still contain additional 0s after decimal based on highest scale value among the involved columns------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|