We help IT Professionals succeed at work.
Get Started

Pick first three characters of a column for Join query in Oracle

chokka asked
Last Modified: 2015-03-10
This is in Oracle.

I have to write an Inner Join query between first set of query and the second set of query.

Second set of query has a column name pri_psl_cd. To this column i need to see the prefix 3 letters matching criteria to the upper join query for the prefix 3 letters of cte.pri_psl_cd. I wonder is there any way to read first three characters of the column and matching with first 3 characters of the second query for that column.

with cte as
select      A.ac_sys_nr,A.ac_nr,A.ac_na,
            trunc(A.ac_opn_dt) open_date,
from        A55601.tacprof A
Inner Join  a55601.tacphas B
on          A.ac_sys_nr = B.ac_sys_nr
Inner Join  a55601.tactosr C
on          A.ac_sys_nr = C.ac_sys_nr
where       A.ac_ad_cny_cd = 'CA'
and         A.dat_cx_tm_prd_nr = 0
and         trunc(A.ac_opn_dt) >= '15-FEB-2015'
and         B.customer_seg_cd <> 'EN'
and         B.cny_cd = 'CA'
and         B.dat_cx_tm_prd_nr = 0
and         B.psl_job_cgy_elg_cd = '2'
and         C.svc_pvr_pyr_nr in ('S13CAEXNP','S13CAEXNA')
select          cte.ac_sys_nr,cte.ac_nr,cte.ac_na,cte.open_date,cte.pri_psl_cd,
from            cte


select * from a55601.tpcplsr 
where  dat_cx_tm_prd_nr = 0
and cny_cd = 'CA'
-- and pri_psl_cd = Pick Prefix of first 3 Letters.

Open in new window

Watch Question
Database Developer & Administrator
Most Valuable Expert 2011
Top Expert 2012
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE