SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Need urgent help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

5 Posts

Posted - 03/05/2014 :  07:38:14  Show Profile  Reply with Quote

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


Premature Yak Congratulator

22847 Posts

Posted - 03/05/2014 :  07:50:21  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000