I plan to have my table have entries (rows) that get activated as time goes on. There's 4 colns. idnumber, startdate, enddate, paiduptodate row 1 1, 1/1/2017, 1/11/2017, 1/11/2017 row 2 2, 12/11/2017, 1/05/2018, 12/02/2018 row 3 3, 1/05/2018, 11/07/2018, NULL row 4 4, 11/07/2018, 10/09/2018, NULL as you can see the start date joins on from the end date of the last entry. and if one entry hasn't fully been paid out then it's still up to that row. How do I write an SQL statement for phpmyadmin to get the highest (max) startdate that has another coln (the paid up to date coln) isn't Null. e.g. In the example above, it would be row 2. row 2 is the active lease. I want to select that entry. Would I use max and group by? and if not isnull? <>?
SELECT MAX(startdate) WHERE paiduptodate != NULL should work, I think? That should return one single row, however, if you have multiple startdates that are the same, this might return unexpected results.