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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Attenndence report absent for last 5 days
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vipinjha123
Starting Member

India
45 Posts

Posted - 05/05/2012 :  05:31:29  Show Profile  Reply with Quote
Dear All,
I am looking for a query in which i can find the employee record who is absent from last 5 days continously.

my tabe structure is like

table name :-login
column

empid logindate

regards,
Vipin jha


khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 05/05/2012 :  05:35:04  Show Profile  Reply with Quote
does the logindate contain time ?
is it one record per day ?

KH
Time is always against us


Edited by - khtan on 05/05/2012 05:35:35
Go to Top of Page

vipinjha123
Starting Member

India
45 Posts

Posted - 05/05/2012 :  05:49:18  Show Profile  Reply with Quote
no it does not contain time

only date
one reecord per day
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 05/05/2012 :  06:11:46  Show Profile  Reply with Quote

select e.empid
from   employee e
where  not exists
       (
           select *
           from   login x
           where  x.empid = e.empid
           and    x.logindate >= dateadd(day, datediff(day, 0, getdate()), -5)
	   and    x.logindate <= dateadd(day, datediff(day, 0, getdate()), -1)
        )



KH
Time is always against us

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.03 seconds. Powered By: Snitz Forums 2000