php - SQL - Query Help: Finding a Local Maximum -


I have a table with graph data.

For example

  index value 0 3 1 5 2 7 3 6 4 8 5 9 6 12 7 11 8 10 9 14 10 13  

I need a query that gives the result where the value is at a local maximum, i.e. the value index of a particular index is greater than the value of + 1 and index -1.

For an example set, it should return the index list: 2, 6, 9 7, 7, 12, 14.

I am using PHP with SQLite. I can do this in PHP with a foreach-loop, but wondering if this is an easy way to use just the SQL command.

Any input will be appreciated.

By doing so with a single loop in PHP it can be very fast in SQL queries, But if you really want to join yourself in the table with something like:

  Select from B.andx as the number, in the form of the number B, the form of the number C In WHERE a.index = b.index-1 and c indices = bindex + 1 and a.value & lt; B.value and c.value & lt; B.value  

(unchecked, so * cross fingers *.)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -