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 |
guptaalok12
Starting Member
5 Posts |
Posted - 2008-09-24 : 03:22:49
|
MaxMarks MarksObtained100 40150 5075 34this is my table(stu) ,i want the percentage of total marksselect sum(MarksObtained)/Sum(MaxMarks) * 100 from Stubut it is not working........Pls help Thanksalokgupta |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-24 : 03:30:46
|
quote: Originally posted by guptaalok12 MaxMarks MarksObtained100 40150 5075 34this is my table(stu) ,i want the percentage of total marksselect sum(MarksObtained)/Sum(MaxMarks) * 100.0 from Stubut it is not working........Pls help Thanksalokgupta
since You're dividing ineteger value by another integer value, you'll get only the integer result. So multiply by 100.0 to cast it to float implicitly and then you'll get correct value. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-24 : 03:56:48
|
select 100.0 * sum(MarksObtained) / Sum(MaxMarks) from Stu E 12°55'05.63"N 56°04'39.26" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-24 : 04:56:55
|
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|