sql - oracle regexp_substr to fetch string -
i have sql query
select count(distinct empno), count(distinct(deptno empname empid )) emp
i want fetch first occurrence of count , content like:
count(distinct empno)
i have tried following sql statement not working,
sql >select regexp_substr('select count(distinct empno), count(distinct(deptno)) emp', 'count *( distinct .)') dual ;
regexp_substr('selectcount(distinctempno),coun ---------------------------------------------- count(distinct empno), count(distinct(deptno ))
i want output return :
regexp_substr('selectcount(distinctempno)
count(distinct empno),
regular expression should not match second ) closing bracket , should match 1st closing bracket.
*
in regex ates everything, need make regex engine match shortest possibility.
count *\([^\)]\)(?=,)
Comments
Post a Comment