we have lot of accounts like this..
real one
id meternumber AccNumber firstReadingDate lastReadingDate
1 2T29 092 **2012-05-19** 2016-03-30
3 151 092 1999-12-31 **2013-06-24**
How to compare firstreadingdate with lastreadingdate to list the accounts that first reading date must not less than lastreadingdate of another meter number. Should have to come as like below
needed as like below.
id meternumber AccNumber firstReadingDate lastReadingDate
1 2T29 092 **2013-06-24** 2016-03-30
3 151 092 1999-12-31 **2012-05-19**
Actual table with active and deactive meter
id meternumber AccNumber Active firstReadingDate lastReadingDate 170085 2T29 092 0 2012-05-19 2016-03-30 184022 151 092 0 1999-12-31 2013-06-24 170087 2T29 092 1 2016-03-31 NULL