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 2012 Forums
 Transact-SQL (2012)
 Rounding Up

Author  Topic 

chipembele
Posting Yak Master

106 Posts

Posted - 2013-11-07 : 12:04:15
Hello. Can someoen help me on this please?

I'm trying to make this round up as currently where something is 85.65 its reporting as 85

CASE WHEN [Possible Attendance] IS NULL OR [Possible Attendance] = 0 THEN NULL ELSE 100 * [Actual Attendance] / [Possible Attendance] END AS PercentageAttendance


Any help much appreciated

Thankyou

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-07 : 13:14:16
[code]
CASE WHEN [Possible Attendance] IS NULL OR [Possible Attendance] = 0 THEN NULL ELSE 100.0 * [Actual Attendance] / [Possible Attendance] END AS PercentageAttendance
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2013-11-08 : 08:24:10
Thanks
Doesnt quite do what I want it to but its workable
Regards
Chip
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-11-08 : 08:39:11
If you want to really ROUND, use the ROUND function, or cast to decimal - either of the following:
CASE 
WHEN [Possible Attendance] IS NULL OR [Possible Attendance] = 0 THEN NULL
ELSE ROUND(100.0 * [Actual Attendance] / [Possible Attendance],0)
END AS PercentageAttendance

CASE
WHEN [Possible Attendance] IS NULL OR [Possible Attendance] = 0 THEN NULL
ELSE CAST(100.0 * [Actual Attendance] / [Possible Attendance], as decimal(18,0))
END AS PercentageAttendance
Go to Top of Page

chipembele
Posting Yak Master

106 Posts

Posted - 2013-11-08 : 08:47:07
Thankyou
Go to Top of Page
   

- Advertisement -