How to sum up an Oracle select case

Asked

Viewed 69 times

1

I am trying to make a sum in a select case, but apparently it is not valid, the following error appears " ORA-01858: a non-numeric Character was found Where a Numeric was expected". when I remove the "+1" from the code works, but I need it kkk

select case 
    when to_number(to_char(data,'D')) < to_number(to_char(to_date('01-jan-'||to_char(data,'RRRR')),'D')) then to_number(to_char(data,'WW'))+1
        else to_number(to_char(data,'WW'))
 end AS Semana_Certa 

from production

  • Hello to you, Matheus! I tried to reproduce your mistake but I could not, I took your query and replaced the "date" with "sysdate" and includes the clause "from" (I think you forgot it) and ran without problems, give us more details so we can help you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.