我试图在两个单独的DATETIME列中返回具有最高日期的表中的记录。
例如:
--------------------------------------------------------------
| ID | DATE1 | DATE2 | OTHERDATA |
--------------------------------------------------------------
| 1 |2016-02-16 17:14:10| NULL | 3 |
--------------------------------------------------------------
| 2 |2016-02-29 10:14:51| 2016-03-03 12:43:39 | 3 |
--------------------------------------------------------------
| 3 |2016-03-03 12:43:39| 2016-03-10 01:00:00 | 3 |
--------------------------------------------------------------
MYSQL查询我要远:
SELECT *, GREATEST(COALESCE(DATE1,0),
COALESCE(DATE2,0))
FROM Table
WHERE OTHERDATA = 3
GROUP BY OTHERDATA;
我希望此查询返回ID 3 ,而是返回ID 1 。我假设它与NULL有关但我认为COALESCE会处理它?有什么想法吗?
答案 0 :(得分:0)
AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(PtLogin.this);