Skip to content
Advertisement

Find turning points in rows with SQL or LINQ

Lest say I have the following data:

I’m looking for an SQL or LINQ Query where I can find all rows with a turning point where the value goes up or below a given value, let’s say 5.

Advertisement

Answer

Use lag() and filtering:

Note that lag() is a standard SQL function available starting in MySQL 8+.

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