Let me know how to find turning price points in stock data in SQL. for example we have following data columns and N rows:
Date |Price|
20150101 | 100 |
20150102 | 50 |
20150103 | 80 |
.
.
.
201708027 | 200 |
and I want to find the turning points (date and price) , to understand clearly check following image.please help me how to find red points.
Using
SELF JOIN
:Using
LEAD
andLAG
will be much more readable but they are available fromSQL Server 2012+
.