Geeks With Blogs

David Madden Mastering the craft one mountain at a time.
If you have to display a two numbers and a percentage from older T-SQL you can do the following.

cast((((cast((query1) as decimal) / cast((query1) as decimal)) * 100)) as decimal(5,1)) as 'Percentage'

This will yield you a nice percentage like 67.9.  All the casting is to preserve the numbers as decimals and not be boxed to integers.  Note: Each query should return a count of something where query 2 is a quantity that is lesser than query1.  Such as query2 being the total who like dessert and query 1 is the total who had meals.
Posted on Tuesday, April 23, 2013 1:26 PM | Back to top

Comments on this post: Casting it old school

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DavidMadden | Powered by: