📜  sql代码示例中的值之间的差异

📅  最后修改于: 2022-03-11 15:05:16.779000             🧑  作者: Mango

代码示例1
SELECT     
city,
    year,
      population_needing_house,
      LAG(population_needing_house)
      OVER (PARTITION BY city ORDER BY year ) AS previous_year
      population_needing_house - LAG(population_needing_house)
     OVER (PARTITION BY city ORDER BY year ) AS difference_previous_year
FROM     housing
ORDER BY city, year