Skip to content
Advertisement

Deducting values from 2 case statements from one another

I have two CASE statements and I’m trying to deduct the value of one from another, but I can’t get the code to work. Does anyone have any suggestions where I’m going wrong?

The 2 CASE statements are:

and

When I try to combine these I get errors (missing right parenthesis). The combined code is:

as “CALENDAR DAYS”,

Advertisement

Answer

Forpas is right about the aliases; you also want to remove all those TO_CHAR() calls. You want to be doing arithmetic with dates, not with strings of characters. I think you’re trying to remove the time portion of the date, and the function you want for that is TRUNC().

Output:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement