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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

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

mukejee
Starting Member

5 Posts

Posted - 03/05/2014 :  07:38:14  Show Profile  Reply with Quote
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

India
22864 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

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000