February 17, 2009 at 2:15 am
Hi,
I am using the following query to find the top 10 transaction and percentage of transaction which is giving percentage in integer only. I tried with 100.0 in stead of 100 which is giving 16.466666666666%. But i want percentage like 16.47%, 13.33%. Any Help please
SELECT TOP 10 DFS_Request_Received as trans,((DFS_Request_Received*100)/(case Total.totalTrans when 0 then 1 else Total.totalTrans end)) as Percentage
FROM DFS,
(select sum(DFS_request_received) as totalTrans from DFS) Total
order by trans desc
February 17, 2009 at 2:37 am
Try this...
SELECT TOP 10 DFS_Request_Received as trans
,ROUND(((DFS_Request_Received*100.0)
/(case Total.totalTrans when 0 then 1 else Total.totalTrans end)),2) as Percentage
FROM DFS,
(select sum(DFS_request_received) as totalTrans from DFS) Total
order by trans desc
February 17, 2009 at 2:53 am
Hi
select (1*100)/9 which will give the result as 11
select (1*100.0)/9 which will give the result as 11.111111
select round(((1*100.0)/9),2) which will give the result as 11.110000
but i want the result as 11.11 only
How to remove the trailing zeros? Any suggestion?
February 17, 2009 at 3:09 am
select cast(round(((1*100.0)/9),2) as decimal(5,2))
February 17, 2009 at 3:16 am
Hi
Thank you. CAST function worked for me
Latha
July 15, 2019 at 9:40 pm
Hi
select 100*(24698891)/39552506
i need answer 62.44
How can i reach the requirement? Any suggestion?
Thanks in advance
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply