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 |
|
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2007-11-06 : 01:38:33
|
| I have fields which data types are int.How do I do a calculation & change it to decimal as im getting a 1.5 value. Here is my SQLFirst I want to minus a.Field1 AND b.Field1 then multiply the answer by c.Field1 then Divide the end result by 100.Have I added it in the correct order & change the end result to a decimal so it can show a 1.5select (a.Field1 - b.Field1) * c.Field1 / 100 AS Field1AmountFROM Table1 AS aINNER JOIN Table2 AS b ON a.Field2 = b.Field2INNER JOIN Table3 AS c ON a.Field2 = c.Field2 WHERE a.Field2 = @Field2 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-06 : 01:50:19
|
| Use 100.0 instead of 100MadhivananFailing to plan is Planning to fail |
 |
|
|
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2007-11-06 : 02:21:53
|
| It works but I get a number as 1.500000.How do I get rid of the leading zeros |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-06 : 02:32:38
|
There are no leading zeros.Do you mean trailing zeros? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2007-11-06 : 02:34:29
|
| Any other way to do this. The end result is currency.a.Field1 = 5b.Field1 = 2c.Field1 = 505 - 2 = 3 3 * 50 = 150150 / 100 = 1.5Answer I want is 1.5I change it to currency in C# R 1.50 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-06 : 02:54:11
|
| If you use C# then you can format the result thereMadhivananFailing to plan is Planning to fail |
 |
|
|
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2007-11-06 : 03:05:05
|
| Thanks so much. It is working....This site is great help. this is my first source of help when stuck with a sql problem.Thanks again guys. Much appreciated....... !! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-06 : 03:15:26
|
quote: Originally posted by u2envy1 Thanks so much. It is working....This site is great help. this is my first source of help when stuck with a sql problem.Thanks again guys. Much appreciated....... !!
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|