Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gksharma
Starting Member
11 Posts |
Posted - 2007-08-22 : 02:35:46
|
select convert(decimal(5,2),(7058/7482)*100 ,0) is shwoing me .00 value instead of 94.33. How to resolve it.Thanks & Regards |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-22 : 02:51:01
|
select convert(decimal(5,2),(7058/7482.0)*100 ,0)See what the major change isMadhivananFailing to plan is Planning to fail |
 |
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2007-08-22 : 02:53:02
|
try this..select (7058.00/7482.00)*100 |
 |
|
gksharma
Starting Member
11 Posts |
Posted - 2007-08-22 : 03:40:44
|
Yes, these are running; but my basic query is something like this :select a.area,a.total,b.pass from (select area,count(*) as total from mytable group by area) a,(select area,count(*) as pass from mytable where (result='1ST' or result='2ND') group by area) bwhere a.area=b.areaorder by a.areaNow i want to create one more column here showing percentage of pass candidate i.e. based on pass/total*100Thanks |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-22 : 04:20:20
|
Tryselect a.area,a.total,b.pass,1.0*b.pass/a.total*100 as percentage from (select area,count(*) as total from mytable group by area) a,(select area,count(*) as pass from mytable where (result='1ST' or result='2ND') group by area) bwhere a.area=b.areaorder by a.areaMadhivananFailing to plan is Planning to fail |
 |
|
gksharma
Starting Member
11 Posts |
Posted - 2007-08-22 : 05:51:04
|
Thank You Madhivanan....!This bit help resolved my big problem...!Thanks AgainRegardsGirish |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-22 : 06:35:41
|
quote: Originally posted by gksharma Thank You Madhivanan....!This bit help resolved my big problem...!Thanks AgainRegardsGirish
Well. You need to be careful when you divide two integers. To get accurate result you need to multiply it by 1.0MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|