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 2008 Forums
 Transact-SQL (2008)
 Attenndence report absent for last 5 days

Author  Topic 

vipinjha123
Starting Member

45 Posts

Posted - 2012-05-05 : 05:31:29
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)

17689 Posts

Posted - 2012-05-05 : 05:35:04
does the logindate contain time ?
is it one record per day ?

KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

vipinjha123
Starting Member

45 Posts

Posted - 2012-05-05 : 05:49:18
no it does not contain time

only date
one reecord per day
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-05 : 06:11:46
[code]
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)
)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -