I've created a query that gives prices for every product ordered by creation date.
What I now need is to only return one row per product, i.e. one price per product.
SELECT p.product_id, p.price, p.creation_date
FROM PRICE p
INNER JOIN PRODUCT pr
ON p.product_id = pr.product_id
AND p.filter_id = 3
AND (p.store_id IN (1,2,3,4) OR p.price_type = 'A')
ORDER BY p.creation_date DESC
Currently this query returns several prices per product, since several match, but I only want the newest one of those. The ORDER BY p.creation_date DESC gives the price I want as the first in the list, I want that first entry to be the only result for that product.
I've tried rownum = 1, but that only gives one result for the whole query. Please note that this is an Oracle Database, so as far as I know TOP does not work, same goes for LIMIT.
I've treid googling it, but I can't find examples showing exactly this issue.
I forgot to mention: There are some prices which have the same creation date for the same product, so there has to be a limit of only giving the first entry for those too