1

我对组功能的使用无效,不确定问题出在哪里

预期结果是从最大可用时间开始的 xxx 秒内的时间戳列表

请指教。

选择时间戳,response_time
从结果
WHERE id = XYZ AND 之间的时间戳
(SELECT MAX(timestamp) FROM results inn WHERE id = 22) AND
(从结果中选择时间戳,其中 id = 22 AND 时间戳 = MAX(timestamp) - XXX)
ORDER BY 时间戳 DESC

谢谢你

4

1 回答 1

2
SELECT  timestamp, response_time
FROM    results
WHERE   id = @xyz
        AND timestamp BETWEEN
        ( 
        SELECT  MAX(timestamp)
        FROM    results
        WHERE   id = 22
        ) AND
        ( 
        SELECT  MAX(timestamp)
        FROM    results
        WHERE   id = 22
        ) - @xxx
ORDER BY
        timestamp DESC

确保您有一个索引,(id, timestamp)以便快速工作。

于 2010-11-11T13:29:59.813 回答