答案 0 :(得分:1)
您可以为每个PID获取最新(inserted_date),然后将其用作单独的表。
例如:
SELECT P.PID, S.SID, P.PRODUCTNAME, S.PRICE, S.COUNT, S.INSERTED_DT FROM
PRODUCT P
INNER JOIN
(
SELECT PID, MAX(INSERTED_DATE) AS LATEST_DT FROM STOCK
) P1 ON P.PID = P1.PID
INNER JOIN STOCK S ON S.PID = P.PID AND S.INSERTED_DATE = P1.LATEST_DT