SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Rounding Up
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chipembele
Posting Yak Master

106 Posts

Posted - 11/07/2013 :  12:04:15  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 11/07/2013 :  13:14:16  Show Profile  Reply with Quote

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


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

chipembele
Posting Yak Master

106 Posts

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

James K
Flowing Fount of Yak Knowledge

3323 Posts

Posted - 11/08/2013 :  08:39:11  Show Profile  Reply with Quote
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 - 11/08/2013 :  08:47:07  Show Profile  Reply with Quote
Thankyou
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000