I have a table consisting of daily stock market data. It consists of a different number of lines for each day. I have a column named "High" in the table. Now I need to calculate MAX (High) for the last 3 weeks. For example: if today is Wednesday, I need to calculate MAX last week on Friday and this week on Monday, Tuesday. I know that I can do this if I know the date manually using such a query.
Select MAX(HIGH) from table_name where date>='date'
But I don’t want to do this, I just want to automate this with a program written in PHP. How can I get this help in PHP or SQL. My table has a total of 6 columns
date,time,open,high,low,close
let's say my table looks like this
date time open high low close
2015-05-06 09:30:00 2012.50 2020.5 2016.5 2014.0
2015-05-06 09:31:00 2013.50 2021.5 2014.5 2016.0
2015-05-06 09:32:00 2014.50 2021.75 2017.5 2013.0
2015-05-07 09:30:00 2011.50 2019.5 2018.5 2014.0
2015-05-07 09:31:00 2014.50 2022.5 2016.5 2015.0
2015-05-07 09:32:00 2012.50 2026.5 2017.5 2016.0
2015-05-08 09:30:00 2010.50 2024.5 2015.5 2017.0
2015-05-08 09:31:00 2013.50 2026.5 2017.5 2018.0
2015-05-08 09:32:00 2014.50 2028.5 2015.5 2019.0
2015-05-08 09:33:00 2014.50 2022.5 2017.5 2012.0
2015-05-11 09:30:00 2017.50 2025.5 2018.5 2013.0
2015-05-11 09:31:00 2018.50 2027.5 2019.5 2016.0
2015-05-11 09:32:00 2019.50 2024.5 2011.5 2017.0
2015-05-11 09:33:00 2020.50 2026.5 2017.5 2014.0
2015-05-12 09:30:00 2018.50 2023.5 2018.5 2018.0
2015-05-12 09:31:00 2017.50 2024.5 2017.5 2014.0
2015-05-12 09:32:00 2018.50 2023.5 2018.5 2013.0
2015-05-12 09:33:00 2017.50 2024.5 2019.5 2014.0
2015-05-12 09:34:00 2016.50 2023.5 2016.5 2012.0
2015-05-12 09:35:00 2017.50 2025.5 2018.5 2011.0
2015-05-13 (), MAX () 3- i.e 2015-05-12,11,08, 2028,5.