How to write a query to print the output enclosed within single quote and percentage
SELECT employee_id FROM employee where employee_name='SMITH';
Output is 76123
How to write a query in Oracle to print the output as follows
'%76123%'
Using concatenation is one option.
SQL> select chr(39) || '%' || empno || '%' ||chr(39) as result
2 from emp
3 where rownum = 1;
RESULT
--------------------------------------------
'%7369%'
SQL>
chr(39)
is a single quote (simpler to use it than repeating several single quotes):
SQL> select '''%' || empno || '%''' as result
2 from emp
3 where rownum = 1;
RESULT
--------------------------------------------
'%7369%'
SQL>