Subject | SQL question |
---|---|
Author | Jerome Bouvattier |
Post date | 2004-02-24T19:22:05Z |
Hello,
Given the following statement :
SELECT P.ID, P.PRODUCTID, P.OUTLETID, P.VALUEDATE, P.SALEPRICE, P.FACING
FROM PRESENCE P
WHERE
(
(PRESENCE.OUTLETID IN (112169, 112170, 112171, 112172, 112173, 112174,
112175))
and
(PRESENCE.VALUEDATE >= '2003-09-01')
and
(PRESENCE.VALUEDATE < '2003-11-01')
and
(PRESENCE.STATUS = 2)
)
order by P.PRODUCTID, P.OUTLETID, P.VALUEDATE
How to modify it so that, for each [PRODUCTID, OUTLETID] combination, only
the *record* with the greatest VALUEDATE is returned ?
Thanks.
--
Jerome
Given the following statement :
SELECT P.ID, P.PRODUCTID, P.OUTLETID, P.VALUEDATE, P.SALEPRICE, P.FACING
FROM PRESENCE P
WHERE
(
(PRESENCE.OUTLETID IN (112169, 112170, 112171, 112172, 112173, 112174,
112175))
and
(PRESENCE.VALUEDATE >= '2003-09-01')
and
(PRESENCE.VALUEDATE < '2003-11-01')
and
(PRESENCE.STATUS = 2)
)
order by P.PRODUCTID, P.OUTLETID, P.VALUEDATE
How to modify it so that, for each [PRODUCTID, OUTLETID] combination, only
the *record* with the greatest VALUEDATE is returned ?
Thanks.
--
Jerome