dimanche 28 juin 2015

How to use partition to select only the desired row?

Here is my table:

table1:
id_nbr                 op_nbr
123E0100               HTM
123E0102               FO
145E0102               HTM
145E0104               FO
198E0100               HTM
234E0100               JAV
234E0102               FO

123E0102, 145E0104 are the id_nbrs I need selected.

For both of them, there exists an id_nbr that matches on the first 6 characters. Op_nbr associated with the originl ID_nbrs are HTM. Last 2 characters increment by 2.

Give me all rows where first 6 characters are equal and last 2 characters is 02 higher than the row with op_nbr HTM associated.

Any help or input is appreciated. Thank You

Aucun commentaire:

Enregistrer un commentaire