Try this sample!
Create Table employee
(
empid Int Identity(1,1) Primary Key Not Null,
empname Varchar(100)
)
Go
Insert employee(empname) Values('Pandian')
Insert employee(empname) Values('Mani')
Insert employee(empname) Values('Raj')
Insert employee(empname) Values('Kv')
Insert employee(empname) Values('Naveen')
Go
Create Table attandance
(
id Int Identity(1,1) Primary Key Not Null,
empid Int Foreign Key References employee(empid),
dateofprent DateTime,
timein Time,
timout Time
)
Insert attandance(empid,dateofprent,timein,timout) Values(1,'2012-04-10','09:00','18:00')
Insert attandance(empid,dateofprent,timein,timout) Values(1,'2012-03-10','09:00','18:00')
Insert attandance(empid,dateofprent,timein,timout) Values(2,'2012-03-10','09:00','18:00')
Insert attandance(empid,dateofprent,timein,timout) Values(3,'2012-04-10','09:00','18:00')
Insert attandance(empid,dateofprent,timein,timout) Values(4,'2012-03-10','09:00','18:00')
Insert attandance(empid,dateofprent,timein,timout) Values(5,'2012-04-10','09:00','18:00')
go
select E.empname from employee E Left Join attandance A
On (E.empid = A.empid And Year(a.dateofprent) = 2012 and Month(a.dateofprent) = 4)
Where A.empid is null
go
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Haider_Sigma, if this helps please login to Mark As Answer. | Alert Moderator