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 |
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2002-02-24 : 02:03:56
|
| I have:TABLE ACOLUMN: A intCOLUMN: B intCOLUMN: C decimalI am trying to UPDATE TABLE A COLUMN C AS result from calculation from COLUMN A & B. I mean UPDATE TABLE A SET C=(A/B)*100 I am trying to receive a something as a percentage. But anytime I receive the result with a round value EXAMPLE: (123/1234)*100=9.97 but I receive in COLUMN C 9.00; I tryed with CAST & CONVERT function but without success. When I changed COLUMN A and B to decimal there is no problem, everything is all right.However, Could somebody help me with a query to calculate the example above without changing COLUMN data types? |
|
|
samrat
Yak Posting Veteran
94 Posts |
Posted - 2002-02-24 : 03:01:09
|
| Try this out, and see how u goUPDATE Table1 SET C = (cast(A as decimal)/cast(B as decimal)) *100Cheers,Samrat ValaniEdited by - samrat on 02/24/2002 03:02:29 |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-02-24 : 05:24:45
|
| alsoUPDATE Table1 SET C = 100.0 * A / Bshould work.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|