![]() |
Select date time for the different status of the field
I am looking for help to select the datatime of the particular status .. 1) Min date time for staus 1 and 2) Max date time for status 2
+---------------------+--------+ | online | status | +---------------------+--------+ | 2012-10-09 21:30:12 | 1 | | 2012-10-09 22:30:24 | 0 | | 2012-10-09 23:30:44 | 1 | | 2012-10-09 23:30:47 | 0 | +---------------------+--------+ Min time of status 1 and max time of status 0 is required please |
Code:
SELECT MIN( IF(status=1,online,'2099-12-31') ) AS minStatus1, |
You could also force the code to get a NULL if there isn't any match on status=1 or status=2, if you need that:
Code:
SELECT IF( x.s1 = '2099-12-31', NULL, x.s1 ) AS minStatus1, |
| All times are GMT +1. The time now is 03:16 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.