Question

The problem I can not get the latest code. I need it to generate the next.

Example:

 Last:
 D11.0602.166

 Next:
 D11.0603.166

I've tried:

 MAX
 TRANSLATE
 CONVERT
 MID
 VAL
Was it helpful?

Solution

What you have there is a "smart key" - one attribute comprising three elements. Smart keys are dumb, because they're a pain in tha neck to work with.

So the correct solution will be to split that attribute into three separate attributes and make it a composite key instead.

In the meantime you could use reguklar expressions to fin dthe highest value of the middle component...

select max(regexp_replace(dumb_key
               , '([A-Z][0-9]{2})\.([0-9]{4})\..([0-9]{3})'
               , '\2'))
from your_table
/

No doubt there are all sorts of other complexities you haven't explained, which means this probably isn't the compleat solution. But it should be a starter for ten.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top