So I have a DB that looks like this:
It contains prices for items with timestamps. I need to return most recent prices from different shops for the same item along with the difference in a single row, so it looks like this:
I'm farily new to SQL, and I just couldn't wrap my head around this task. I was able to return the list with all needed info:
select i1.item, i1.shop, i1.last_modified, i1.price
from items i1
inner join(
select item, max(last_modified) as MaxLastModified
from items group by item) groupedi1
on i1.item = groupedi1.item
and i1.last_modified = groupedi1.MaxLastModified;
but to order it in a single row is beyond me for now.

