Home > database >  Help: SQL query rule out non-adjacent record start time and end time
Help: SQL query rule out non-adjacent record start time and end time

Time:09-25


I use a few form joint generated such a view:


This view, we need to keep near the start and end time, don't rule out adjacent records, such as above the first row,

I wish good!
Feng Sihao



CodePudding user response:

How to calculate the adjacent,,,

CodePudding user response:

reference 1st floor acen_chen response:
how to calculate adjacent,,,


You look at the record:
A start should correspond with the start time only the last until the end of time
If the start time is corresponding to the other end time, need to rule out,

CodePudding user response:

The first record is the need to rule out,

CodePudding user response:

 select id, ks and js from 
(select id, ks, js, row_number () over (partitions by id, ks order by js) rn
The from view_tmp
) t
Where t.r n=1;

CodePudding user response:

reference 4 floor js14982 response:
 select id, ks and js from 
(select id, ks, js, row_number () over (partitions by id, ks order by js) rn
The from view_tmp
) t
Where t.r n=1;


Like it doesn't, but unknown folded,

CodePudding user response:

Select id, ks and js from
(select id, ks, js, row_number () over (partitions by id, ks order by (js - ks)) rn
The from view_tmp
) t
Where t.r n=1;

CodePudding user response:

  • Related