标签:
一、思路:首先查询在某个时间段中最新时间的字段,然后用查到的字段与原来的表作自连接,最后对自连接后的表进行所需字段的查询。
二、sql语句:
SELECT
*
FROM
(
SELECT
max(i.createDate) AS createDate,
r.websiteConfigInfo_id AS webId
FROM
run r
WHERE
r.staticsEndTime BETWEEN : beginTime
AND : endTime
AND r.websiteConfigInfo_id = : websiteId
) AS r1
JOIN run r2 ON (
r1.createDate = r2.createDate
AND r1.webId = r2.websiteConfigInfo_id
)
标签:
原文地址:http://www.cnblogs.com/lusunlufar/p/4377635.html