我正在使用支持 SQL92 的 OLEDB 接口查询数据系统。我的查询问题等同于这里解决的问题:SQL Query to find early date取决于 column value changes,但是那里提供并复制下面的解决方案对于 SQL92 来说太高级了:
SELECT JobCodeId, MIN(LastEffectiveDate) AS mindate
FROM (
SELECT *,
prn - rn AS diff
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY JobCodeID
ORDER BY LastEffectiveDate) AS prn,
ROW_NUMBER() OVER (ORDER BY LastEffectiveDate) AS rn
FROM @tmp
) q
) q2
GROUP BY
JobCodeId, diff
ORDER BY
mindate
该解决方案的 SQL92 兼容版本会是什么样子?