Home > database >  How can the SQL queries to the difference of two records
How can the SQL queries to the difference of two records

Time:09-15

Rookie beginners, encounter a problem, I define the structure of the TABLE1 is time, figures 1, 2, data... Data can be selected according to the scope of the time now, but also want to in this time range to calculate each data after a difference of data and a data before? I don't know what is the format?

CodePudding user response:

Start sql2012 can use lag window culvert
Can after row_number self before connection

CodePudding user response:

Remained roughly the same is with top 1 access conditions, in reverse chronological order to obtain the latest record, advice or make a simple demand case
 SELECT TOP 1 value from Table A 
Where A.Value=https://bbs.csdn.net/topics/B.Value and B.T ime From Table B
  • Related