Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Need urgent help

Author  Topic 

mukejee
Starting Member

5 Posts

Posted - 2014-03-05 : 07:38:14
Experts,

Need a help urgently.

I am having below tables

Table1- Standard

ID Startdatetime EndDatetime
1 10.00AM 11.00AM

Table-Attendance Table

EmpNo StartDateTime EndDateTime
1 10.00AM 11.05AM
2 9.45 AM 10.45AM
3 10:00 AM 11.00AM
4 10:05 AM 11.00AM

Here I want to get the Emp No who are there in the time slot of standard table. ie between 10.00AM to 11.AM.

Here the total number of emp = 2 ( ID-1,3)
Please help me to write this SQL

Regards
Mukesh

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-05 : 07:50:21
What is the datatype of datetime columns?

select attend.empno from attendance as attend inner join standard as std
on attend.Startdatetime <=std.Startdatetime and std.EndDatetime<=attend.EndDatetime

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -