我已经成功地将这项工作仅用于一排。但是如何使它适用于零件编号列表?
SELECT
T.PART_NO,
(SELECT SUM(H.VALUE) FROM
(SELECT * FROM HISTORY_TABLE
WHERE PART_NO='100'
ORDER BY A_YEAR DESC , A_MONTH DESC
) H
WHERE ROWNUM <= 12
)
FROM MY_TABLE T
WHERE T.PART_NO = '100'
GROUP BY T.PART_NO