My quess is you get ORA-01722 because you can't sum on a Char column as shown in the below example:
SQL> select sum(case when 1=1 then 'hello' end) from dual;
select sum(case when 1=1 then 'hello' end) from dual
*
ERROR at line 1:
ORA-01722: invalid number
SQL> select sum(case when 1=1 then 1 end) from dual;
SUM(CASEWHEN1=1THEN1END)
------------------------
1
So in your case try:
sum(case when z = 123 and y = 432 then 1 end) as SomeTotal
This doesn't make any sense but I assume you are just testing at the moment
or something?!! Cause it only makes sense to some a column as in:
sum(case when col1 = 123 and col2 = 432 then sumcol end) as SomeTotal
>sum( case
> when z = 123 and y = 432
> then 'hello World'
> end) as SomeTotal
>
>So I guess my question is How can I get around this?
>Thanks in advance
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only