我想同时获得特定值的最小值,以及具有该最小值的行的键。目前,我这样做如下:
SELECT dates.date AS Date, num_apples.apples AS MinApples FROM
(
SELECT date, MIN(apples) AS MinApples, apples
FROM Table
HAVING MinApples = apples
) AS dates
JOIN
(
SELECT date, apples
FROM Table
) AS num_apples
ON (
dates.date = num_apples.date
);
仅使用“标准”(我的意思是通常实现的)SQL 是否有更好的方法来做到这一点?