sql - Comparing fields when a field has data in between 2 characters that match the field being compared -
i have code looks this:
left outer join gme_batch_header bh on substr(ln.lot_number,instr(ln.lot_number,'(') + 1, instr(ln.lot_number,')') - instr(ln.lot_number,'(') - 1) = bh.batch_no
it works fine, have come across few lot numbers have 2 sections of strings between parenthesis. how compare between second set of parenthesis? here example of data in lot number field:
e142059-307-scrap-(74055)
this 1 works code,
58lf-3-b-2-2-2 (scrap)-(61448)
this 1 tries comparing scrap batch no, isn't correct. needs 61448.
the result last item in parenthesis.
after more research, got work code:
substr(ln.lot_number,instr(ln.lot_number,'(',-1) + 1, instr(ln.lot_number,')',-1) - instr(ln.lot_number,'(',-1) - 1)
Comments
Post a Comment