I have problem sql statement, can someone help me?

How are you?

SQL > select * from tst

2 order by id, vacdate;

ID VACDATE VACINTERV

---------- --------- ----------

10-15 JANUARY 13 4

10-25 JANUARY 13 6

10-27 JANUARY 13 4

20-15 JANUARY 13 4

40 1 MAY 13 3

40 13 OCTOBER 13 7

50 13 OCTOBER 13 7

50 17 OCTOBER 13 7

60 24 MAY 13 5

60 24 MAY 13 3

This table contains the id == > employee id & vacdate == > is the start date of the holiday of employees & & vacinterv = > means the time interval of the holidays for example 7 7 days from 13 October 13 until 20 October 13

the problem is there are used (IE id 10) take vacations that overlap [take 25 January 13 (range 6) until 21 January 13] but take by mistake January 27, 13 other vacation causing Holiday overlap

How to select employees who will have a vacation that overlap?

[email protected]

LAG analytical use:

with t as)

Select tbl.*,

case

When trolling (vacdate + vacinterv, 1, vacdate) over (partition by order of identification by vacdate) > vacdate, 1

end overlap_indicator

from tbl

)

Select distinct id

t

where overlap_indicator = 1

/

ID
----------
10
50
60

SQL >

SY.

Tags: Database

Similar Questions

Maybe you are looking for