我需要将以下内容(访问中的sql)转换为mysql。它是按第一个查询分组的,但是obv mysql无法处理第一个或最后一个。
SELECT First([20121202].Date) AS FirstOfDate, First([20121202].Time) AS FirstOfTime, [20121202].HomeMatchingId, [20121202].AwayMatchingId, [20121202].RunningStatus
FROM 20121202
GROUP BY [20121202].HomeMatchingId, [20121202].AwayMatchingId, [20121202].RunningStatus
HAVING ((([20121202].RunningStatus)=1))
基本上我是在比赛(主队v客队)上场的时间之后(runningstatus = 1)
提前致谢
最佳答案
不确定日期是什么,但是使用常规聚合呢?
SELECT
MIN(`Date`) AS `FirstOfDate`,
MIN(`Time`) AS `FirstOfTime`,
`HomeMatchingId`,
`AwayMatchingId`,
`RunningStatus`
FROM `20121202`
GROUP BY
`HomeMatchingId`,
`AwayMatchingId`,
`RunningStatus`
HAVING
`RunningStatus`=1