RSS

Monthly Archives: December 2010

sql Query return the decimal as a percentage


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