Search
 
SCRIPT & CODE EXAMPLE
 

SQL

select value from previous row in postgresql

-- use LAG(column_name, lag) OVER (PARTITION BY x ORDER BY y)
select
	id,
	version,
	start_date,
	lag(dss_end_date, 1) over (partition by id order by version) as previous_row_end_date
	end_date
from
	table
order by
	id,
	version;
Comment

PREVIOUS NEXT
Code Example
Sql :: generate random & unique mysql string 
Sql :: oracle get ddl 
Sql :: how to define a save method in ruby for sql databases 
Sql :: get all employee of salary if more than in sql 
Sql :: sql query inner join 3 tables 
Sql :: POSTGRES INSERT INTO TABLE VALUE FROM OTHER TABLE 
Sql :: sql restore database from backup 
Sql :: oracle inner join 
Sql :: mysql fetch all data 
Sql :: express mysql 
Sql :: oracle gather table statistics 
Sql :: sql union operator 
Sql :: connect to mysql c# connection string C# 
Sql :: initcap in sql 
Sql :: SQL SELECT TOP Equivalent in MySQL 
Sql :: finish transaction sql 
Sql :: An error occurred while installing mysql (2.9.1), and Bundler cannot continue 
Sql :: sql insert data 
Sql :: mysql default port number 
Sql :: mysql create table if not exists 
Sql :: Split JSON data in SQL Server column 
Sql :: microsoft sql server python connection 
Sql :: how to create triggers in sql server 
Sql :: get size of mysql database 
Sql :: select count distinct multiple columns sql server 
Sql :: array aggre distinct postgres 
Sql :: check if table is Temporal 
Sql :: date datatype in livesql 
Sql :: SQL SELECT TOP Equivalent in oracal 
Sql :: delete account in flask and sqlalchemy 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =