I don't understand why this doesn't work. I've used if-then-else before without a problem.
Address Type is VARCHAR2 (2) in an Oracle database. I want to create a sort key for these address types.
if ([ADDRESS_TYPE]='PA')
then 1
else
if ([ADDRESS_TYPE]='PR')
then 2
else
if ([ADDRESS_TYPE]='MA')
then 3
else 0
Parsing error before or near position 32 of "if ([ADDRESS_TYPE]='PA')
then 1"
1. The syntax is If ( ) then () else ()
2. Consider using a case rather than a nested IF. It is cleaner and clearer.