表中数据为:
CardNo Direction PassTime
1768311 5 2016-05-30 10:28:25
1768311 5 2016-05-30 10:28:26
1768311 5 2016-05-30 10:39:13
1768311 5 2016-05-30 11:17:30
1768311 3 2016-05-30 16:05:21
1768311 3 2016-05-30 18:19:55
1768311 2 2016-05-30 18:20:00
查询语句为
SELECT
CardNo,
Direction,
max(PassTime)
FROM
TB_CHANNELPASS
WHERE
PassTime BETWEEN “2016-05-30”
AND “2016-05-31″
GROUP BY
CardNo,
DATE_FORMAT(PassTime,”%y-%m-%d”)
返回结果:
1768311 5 2016-05-30 18:20:00
2016-05-30 18:20:00对应的应该是2,问题出在哪?
CardNo Direction PassTime
1768311 5 2016-05-30 10:28:25
1768311 5 2016-05-30 10:28:26
1768311 5 2016-05-30 10:39:13
1768311 5 2016-05-30 11:17:30
1768311 3 2016-05-30 16:05:21
1768311 3 2016-05-30 18:19:55
1768311 2 2016-05-30 18:20:00
查询语句为
SELECT
CardNo,
Direction,
max(PassTime)
FROM
TB_CHANNELPASS
WHERE
PassTime BETWEEN “2016-05-30”
AND “2016-05-31″
GROUP BY
CardNo,
DATE_FORMAT(PassTime,”%y-%m-%d”)
返回结果:
1768311 5 2016-05-30 18:20:00
2016-05-30 18:20:00对应的应该是2,问题出在哪?
解决方案
40
官方手册的说明很清楚。