1
我有下面的查詢。 SOFTWARE_DEVELOPMENT_CYCLE有多行,但我對最新版本感興趣。Oracle - 用max()重構子查詢
我想重寫查詢,以便我不使用子查詢。我曾嘗試過使用DENSE_RANK LAST ORDERY BY,但無濟於事。
有人建議嗎?謝謝。
SELECT SOF.VENDOR,
SOF.NAME,
LAN.LANGUAGE,
SOF.VERSION,
SDC.STATUS,
SDC.SOF_DC_ID
FROM SOFTWARE SOF
JOIN SOFTWARE_LANGUAGES SL
ON (SL.SOF_SOF_ID = SOF.SOF_ID)
JOIN LANGUAGES LAN
ON (SL.LAN_LAN_ID = LAN.LAN_ID)
JOIN SOFTWARE_DEVELOPMENT_CYCLE SDC
ON (SDC.SOF_LAN_SOF_LAN_ID = SL.SOF_LAN_ID)
WHERE SDC.SOF_DC_ID IN (SELECT MAX(SDC2.SOF_DC_ID)
FROM SOFTWARE_DEVELOPMENT_CYCLE SDC2
WHERE SDC2.SOF_LAN_SOF_LAN_ID = SL.SOF_LAN_ID)
ORDER BY SOF.VENDOR,
SOF.NAME,
LAN.LANGUAGE,
SOF.VERSION;
謝謝。你能否解釋你的過程,以決定如何做到這一點? – retrodev 2012-02-23 16:48:22