1

I have a holidays table for a person, say 'M109'. for a particular date he taken vacation for 1 hour lunch and 4 hour meeting.

eg.

  • 11 am to 3 pm - meeting
  • 12pm to 1pm - lunch.

now I need to hide this 1 hour lunch tuple and get only the meeting tuple. how can i do that ?

table(Person(varchar), StartTime, EndTime, Date, Desciption) is the schema.

My query so far:

select "Provider", sum(b."EndTime" - b."StartTime")/60 as Non
from VACATION b
where b."StartDate" = '18-FEB-13'
and b."StartTime" IN (select p."StartTime"
                      from axium.VACATION p
                      where Exists (select q."StartTime"
                                    from axium.VACATION q
                                    where p."Provider" = q."Provider"
                                    and q."StartTime" <> p."StartTime"
                                    and q."StartTime" between p."StartTime"
                                                      and p."EndTime"
                                   )
                     )
and b."Provider" = 'M1009'
group by b."Provider"
order by b."Provider";
4

1 回答 1

0

您可以使用where子句和相关子查询来做到这一点:

select *
from t
where not exists (select 1 from t t2 where t2.person = t.person and t2.starttime < t.starttime and t2.endtime > t.endtime)
于 2013-02-19T21:30:28.817 回答