## Find the minimum number for a field then change all of the following numbers, if necessary

## Find the minimum number for a field then change all of the following numbers, if necessary

(OP)

Hey

I have data where there could be 1 pattern or multiple patterns.

set pattern

1 1

1 2

1 3

2 2

2 4

3 3

Is there a way in a case when, if or some other expression that I can write that would find the minimum pattern for a set and always make it number 1 then change the sequence if necessary so I would get:

set pattern

1 1

1 2

1 3

2 1

2 2

3 1

Thank you!

I have data where there could be 1 pattern or multiple patterns.

set pattern

1 1

1 2

1 3

2 2

2 4

3 3

Is there a way in a case when, if or some other expression that I can write that would find the minimum pattern for a set and always make it number 1 then change the sequence if necessary so I would get:

set pattern

1 1

1 2

1 3

2 1

2 2

3 1

Thank you!

## RE: Find the minimum number for a field then change all of the following numbers, if necessary

Mufasa

(aka Dave of Sandy, Utah, USA)

“People may forget what you say, but they will never forget how you made them feel."

## RE: Find the minimum number for a field then change all of the following numbers, if necessary

set# pattern# dates

1 1 1/12

1 2 2/13

1 3 2/20

2 2 2/28

2 4 3/12

3 3 2/27

Is there a way in a case when, if or some other expression in a select statement that I can write that would find the minimum pattern for a set and always make it number 1 then change the sequence if necessary so I would get:

set pattern# dates

1 1 1/12

1 2 2/13

1 3 2/20

2 1 2/28

2 2 3/12

3 1 2/27

Thanks for your help!!!

## RE: Find the minimum number for a field then change all of the following numbers, if necessary

There are many ways to achieve your goal. Here is one of the syntactically simpler ways that I can think of:

## CODE

In the above solution, "row_number() over (partiion..." is one of the very handy Oracle Analytic functions.

Let us know if this resolves your need, or if you have follow-up questions.

Mufasa

(aka Dave of Sandy, Utah, USA)

“People may forget what you say, but they will never forget how you made them feel."

## RE: Find the minimum number for a field then change all of the following numbers, if necessary

Thanks