我有一个数据集
--City Brand Cost Date
--Nashville A $100 11/14/2023
--Nashville A $125 11/15/2023
我想看
--City Brand Difference Latest Date
--Nashville A $25 11/15/2023
提前致谢!
与
RankedCombination
分割完毕 是行号 <= 1
等等
以下 sql 在 Oracle 中给出了所需的结果:
select city,brand,difference,datecol
from (select rownum as r,city,brand,
cost - lead(cost) over (order by datecol desc) as difference,
datecol
from t1 order by datecol desc)
where r=1;