Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

the differnece between to values in sql

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
Source by learnsql.com #
 
PREVIOUS NEXT
Tagged: #differnece #values #sql
ADD COMMENT
Topic
Name
8+2 =