| Author |
Topic |
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 03:09:18
|
| Hi,I'm here would like to know whether we can have SQL statement with below condition:Select A, B, C, CASE WHEN A = 0 THEN ((A+B)/2) ELSE 'Proceed' END FinalFigurePls advice. |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-06 : 03:12:42
|
have you tried it already? if you encounter an error then let us know. --------------------keeping it simple... |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 03:27:09
|
| YUP...I have already tried. For ur infor that I'm using Oracle Toad. The Error message I get is "inconsistent datatype". |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-06 : 03:32:39
|
quote: Originally posted by wensen YUP...I have already tried. For ur infor that I'm using Oracle Toad. The Error message I get is "inconsistent datatype".
then check if a and b are numeric types or if their data types allow division--------------------keeping it simple... |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 03:39:39
|
| Oh ya, you are correct, it is in varchar datatype, can it be converted? |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 03:52:50
|
| I have tried to use CAST as below:CAST(A AS NUMBER(12,2))but encounter error... |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-06 : 04:21:49
|
| what's the error?--------------------keeping it simple... |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 06:54:37
|
| same error -> "inconsistent datatype" |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 08:07:16
|
| something to add..I try to use TO_NUMBER function as below:select (TO_NUMBER(A)+ TO_NUMBER(B)) FINALTOTAL from TableNameit works......but when put into the CASE statement it having Inconsistant datatype error....pls advice.. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-06 : 15:55:11
|
| You do know that this is a SQL Server site and not an Oracle one...Brett8-)EDIT: Actually Looking at the home page, unless there's an article, it's not readily apparent |
 |
|
|
wensen
Starting Member
7 Posts |
Posted - 2004-12-06 : 20:26:12
|
| YUP, I know it is SQL server forum, but the SQL statement that are using have some similiar feature, that is why I try to join the forum here... |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-06 : 22:39:03
|
| in mssql, there is a function called convert or cast to change the data type, look for something similar in oracle --------------------keeping it simple... |
 |
|
|
|