How can i do this? I have this table
ββββββββββ¦βββββββββββ¦βββββββββββ
β item β price β date β
β βββββββββ¬βββββββββββ¬βββββββββββ£
β Dollar β 60 β 1.3.2016 β
β Dollar β 50 β 2.3.2016 β
β Bound β 100 β 1.3.2016 β
β Bound β 110 β 2.3.2016 β
β Euro β 600 β 1.3.2016 β
β Euro β 580 β 3.3.2016 β
ββββββββββ©βββββββββββ©βββββββββββ
The output should display one element from each type with the last default of the price on the last date and the price difference from the previous line, for example:
ββββββββββ¦βββββββββββ¦βββββββββββββββββββββββββ
β item β price β date β differnece β
β βββββββββ¬βββββββββββ¬βββββββββββββββββββββββββ£
β Dollar β 50 β 2.3.2016 β -10 β
β Bound β 110 β 2.3.2016 β 10 β
β Euro β 580 β 3.3.2016 β -20 β
ββββββββββ©βββββββββββ©βββββββββββββββββββββββββ
I did it ...
SELECT item,date,price FROM wpdatatable_23 WHERE date IN (SELECT max(date) FROM wpdatatable_23 GROUP BY item LIMIT 0,1) group by item
... and it works fine. I just donβt know how to make a difference, any help?
source
share