Answer the question
In order to leave comments, you need to log in
SQL query to select the current attributes of an entity from a log type table
There is a table where entity attributes are stored, for example, the product ID, its price and the date of the last update. When adding a new price, a row ('item-id', 'new price', 'time of adding') is inserted into the table. How to get a selection with current prices for all products?
Answer the question
In order to leave comments, you need to log in
select id, price, date_modified
from prices where id
,
date_modified in ( select id, max
(
date_modified)
from prices
group by id
) by id order by date_modified desc)
from prices
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question