Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

finding overlapping schedule in a table

$
0
0

Hi,

I am new in SQL developing and have a question to find overlapping schedule based on Startdate/EventStatus/FunctionRoom/StartTime and End Time.

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>

S.NoEventStatusStartDateStartTimeEndTimeFunctionRoomFlag
1Accepted2019-06-054:30 AM9:00 PMBall Room
2Accepted2019-06-055:30 AM8:00 PMBall Room
3Tentative2019-06-0610:00 AM5:00 PMBall Room1
4Accepted2019-06-073:00 PM7:00 PMBall Room2
5Accepted2019-06-0812:00 PM5:00 PMBall Room 3
6Tentative2019-06-0812:00 AM6:00 AMBall Room 4

Need to fill Flag column Y if any overlap schedule find other wise N

Hope i will get SQL statment here and i tried below statement and it's gave different result

update a set Flag ='Y' from [Employee].[dbo].[EventTable]as a Inner Join [Employee].[dbo].[EventTable_Insert] as b
On a.StartDate = b.Startdate and a.FunctionRoom =b.FunctionRoom and a.EventStatus = b.EventStatus
where ((a.StartTime between b.StartTime and b.EndTime) and (a.EndTime between b.StartTime and b.EndTime) and (b.StartTime between a.StartTime and a.EndTime))

Thanks 

Venkat


Regards Venkat


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>