MySQL客户端版本:5.0.24a
嘿伙计,
我有一个WorkOrders_errors表,如下所示:
ID CO CAR NAME CAN BLN INDATE MODDATE EX
66897 461 57 KKLU KKLUSH9862088 AKLU6013312 1/27/2014 1:00 1/27/2014 1:00 -1
60782 461 57 KKLU KKLUHB21629300 AKLU6501153 1/26/2014 22:00 1/26/2014 22:00 1
74188 461 57 KKLU KKLUHB21629300 AKLU6501153 1/27/2014 10:00 1/27/2014 10:00 1
66645 461 57 KKLU KKLUSH8222080 AKLU6501744 1/26/2014 21:45 1/26/2014 21:45 1
63307 461 126 ZIMU ZIMUGOA321986 AMFU3037671 1/27/2014 1:15 1/27/2014 1:15 1
65081 461 24 CMDU CMDUAU1337382 AMFU3043761 1/26/2014 21:30 1/26/2014 21:30 1
72660 461 24 CMDU CMDUAU1337382 AMFU3043761 1/27/2014 9:30 1/27/2014 9:30 1
我只需要具有最新MODDATE的记录,即ID记录74188,而不是60782。 我尝试了几种方法,但没有成功。最近尝试了
SELECT * FROM (
SELECT * FROM WorkOrders_errors ORDER BY ModDate DESC) as tmp
GROUP BY can
ORDER BY can
'还试过
SELECT t1.*
FROM WorkOrders_errors t1
WHERE t1.Can = (SELECT t2.Can
FROM WorkOrders_errors t2
WHERE t2.Can = t1.Can
ORDER BY t2.Can DESC
LIMIT 1)
这两者似乎占用了大量的资源/时间。该表只有大约80,000行。
谢谢任何人!