My data looks like this
8-8-19-66-1-2-22 8-8-19-66-1-2-30 8-8-19-66-1-2-0 8-8-19-65-0-0-0 8-8-19-65-1-2-28 8-8-19-65-2-5-21 I am trying to create a query that trys to find the first solo 0 between the "-" and then prints out all of the columns that have the same values up to the solo 0. I have something, but it is not quite right. select distinct territory ,SUBSTR(territory, 0,INSTR(territory,'-0', 1, 1)-1) as s from eligibility_revenue where fiscal_qtr_nbr=3 and SUBSTR(territory, 0,INSTR(territory,'-0', 1, 1)-1) like SUBSTR('8-8-19-66-1-2-0', 0,INSTR('8-8-19-66-1-2-0','-0', 1, 1)-1) I want this query to produce: 8-8-19-66-1-2-22 8-8-19-66-1-2 8-8-19-66-1-2-30 8-8-19-66-1-2 8-8-19-66-1-2-0 8-8-19-66-1-2 The territory will be passed to the query. In this case: 8-8-19-66-1-2-0. The first solo 0 is at the end, so we should create a query that has a like clause that looks for '8-8-19-66-1-2-' That's where I am struggling and any help would be great. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group. To post to this group, send email to Oracle-PLSQL@googlegroups.com To unsubscribe from this group, send email to oracle-plsql-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Oracle-PLSQL?hl=en -~----------~----~----~----~------~----~------~--~---