Saturday, May 5, 2018

Using SUBSTR in PLSQL Query

https://randomsrsolutions.blogspot.com/2018/05/using-substr-in-plsql-query.html

SUBSTR Extracts a string of a determined Length

select substr('PAKISTAN',4) from dual;
ISTAN

select substr('PAKISTAN',4,3) from dual;
IST

select substr('PAKISTAN',-1,1) from dual;
N

select substr('PAKISTAN',-2,1) from dual;
A

select substr('PAKISTAN',-3,3) from dual;
TAN

Retrieve all Employees whose name begins with S

select ENAME from EMP where substr(ENAME,1,1) = 'S';
SCOTT
SMITH

Retrieve all Employees whose Name Contains A in Second position

select ENAME from EMP where substr(ENAME,2,1) = 'A';
WARD
MARTIN
JAMES

select ENAME from EMP where ENAME like '_A%';
WARD
MARTIN
JAMES

Retrieve all Employees whose name ends with S

select ENAME from EMP where substr(ENAME,-1,1) = 'S';
JONES
ADAMS
JAMES

select ENAME from EMP where ENAME like '%S';
JONES
ADAMS
JAMES

No comments:

Post a Comment

XLA to GL Link

  https://plsqlquery.blogspot.com/2025/12/xla-to-gl-link.html SELECT             acr.cash_receipt_id,             acr.receipt_number,       ...