Following is my code
select (upper(fname)||' '||upper(mname)||' '||upper(lname)) as customer_name,
(indv_corp_flag) as Customer_type,
(regexp_replace(passport_no,'D','B')"regexp_replace") as passport_no,
(case when indv_corp_flag = 'C' then registration_no else null end) as registration_no,
(case when indv_corp_flag = 'I' then marital_status else null end) as Marital_status
from Nbfc_krishnan_m;
it gives error like
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Error at Line: 91 Column: 38
But on operating individually it works like
select
regexp_replace(passport_no,'S','d')"regexp_replace"
from nbfc_krishnan_m;
is successfully executed.
You have wrapped all the columns of your projection in unnecessary brackets. It compiles but the clutter is preventing you from seeing the problem. Without those brackets it becomes clear you have a column with two aliases:
You posted a working query. It works because it has only one alias. Hence the solution is obvious:
In future reserve brackets for expressions which actually need them.
You're just substituting one character for another, so you should use the standard TRANSLATE() function. Only use REGEXP_REPLACE() when you need a regular expression (i.e. a pattern).