RSS

sql Query return the decimal as a percentage

15 Dec

Solution#!

declare @sales int,
@novisits int

select @Sales = 3,
@NoVisits = 1553

select ltrim(str(100.0 * @Sales / @NoVisits, 6, 2))

 

Solution 2

 

 

count(d.Present),ltrim(str(100.0 * (count(d.Present)) /(select top 1 count(d.Present) as Present from tblAttendanceDetail d where d.Present=1  group by d.studentid order by Present desc), 6, 2))as ‘Percentage’

 


Advertisements
 
Leave a comment

Posted by on December 15, 2010 in SQL Query

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: