View previous topic :: View next topic |
Author |
Message |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Tue Jun 13, 2006 10:33 am Post subject: Help with CAST statement |
|
|
Hi ,
I've the following values in 3 columns
column definitions:
A DECIMAL(17, 2) NOT NULL
B DECIMAL(17, 2) NOT NULL
C DECIMAL(15, 8 ) NOT NULL
column values:
A B C
.00 999989990000000.01 1.00000000
.00 999989990000000.01 1.00000000
IN 2 ROWS
i get an sqlcode 802 on this sql.can u help me what I need to here to get the final value .
Code: | SELECT SUM( CAST ( ( A + B )
* ( C) AS DECIMAL(17, 2)
)
)
INTO :W-AMT :W-NULL-VALUE | w-amt S9(15)V9(02) COMP-3.
Thanks,
vijay |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jun 13, 2006 10:47 am Post subject: |
|
|
vijay,
If your intention is to use only 2 decimals then you need to cast column C with 2 decimals instead of 8.
try this sql
Code: |
SELECT (A + B) * CAST((C) AS DECIMAL(7,2))
FROM TABLE;
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Tue Jun 13, 2006 11:11 am Post subject: |
|
|
thanks kolusu.it worked |
|
Back to top |
|
|
|
|