Click here to Skip to main content
15,072,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
cte3_persenta (per) as
(select ((cte1.totalcount/cte2.TotaCount)* 100 )
where cte1.emp=cte2.emp
from cte1,cte2)


i am creating one new cte table shown above
from that value '2'coming from cte1.totalcount and
value '500' coming from cte2.TotaCount
i want percentage of those value it should be in 0.00% format


i want ans of per from cte3 table is =0.40%

please help some one
Posted
Updated 14-Feb-14 19:59pm
v3
Comments
santhu888 13-Feb-14 2:11am
   
Is there any relation between those two tables?
Member 10562086 13-Feb-14 4:39am
   
those two table means Cte1_TotalCount And cte2_totalCount sir?
yes Those two value having Emp_status as common

Please do this..

SQL
select cte1totalcount,cte2totalcount,(cte1totalcount/cte2totalcount)*100 as cet3  from emp_status 
   
SQL
select cte1.totalcount,cte2.totalcount ,(cte1.totalcount/cte2.totalcount)*100 as cte3_persent from cte1 join inner cte2 on cte1.emp=cte2.emp 
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900