Skip to content
Advertisement

how to check the number continure or not in postgreSQL?

Hi I have database like:

I want to check the lownumber and highnumber contine or not. I mean the previous highnumber + 1 equal the next line lownumber or not? how to do that in postgresql?

Advertisement

Answer

You can get the exceptions using lag():

Note: “previous” is ambiguous. I don’t know from the question if it refers to the previous row based on id or lownumber. If the latter, then change the order by.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement