Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, I have to tables name timesheet and employee.
where timesheet table contains employeeid,startdate,enddate columns and
employee table contains employeeid,employeename columns.
now if i want to know the employeename who has not fill the timesheet on a particular day.

Thanks in Advance.
Posted
Comments
krumia 22-Feb-12 4:22am    
What you need to do is not called 'Union'. Its called 'Join'. SQL UNION is something else.

Hi,

First of all i would like to tell you that no need to use UNION to get such result.

You Solution Here:
SQL
SELECT * FROM Employee WHERE EmployeeID NOT IN (SELECT EmployeeID FROM TimeSheet WHERE StartDate>='YYYY-MM-DD' AND EndDate<='YYYY-MM-DD')
 
Share this answer
 
SQL
Select e.employeename 
from employee e join timesheet t 
where e.employeeid=t.employeeid
and t.startdate is null 
or t.enddate is null
 
Share this answer
 
Hey,
Try this
SQL
select employeename from employee emp inner join timesheet ts on emp.employeeid =ts.employeeid
where startdate=null or enddate=null


Good Luck
 
Share this answer
 
Hi...!
click the link and u will found how to use UNION OR UNION ALL Operator in your project..!
http://www.mssqltips.com/sqlservertip/1387/joining-data-using-union-and-union-all-in-sql-server/[^]
 
Share this answer
 
Hi Mayank,

This might help you

Table1 - Timesheet
Columns - employeeid, startdate, enddate

Table2 - employee
Columns - employeeid,employeename


this is a query you can perform - query format [SQL SERVER]

SQL
SELECT DISTINCT e.employeeid,e.name
FROM employee e
left outer join timesheet t on t.employeeid = e.employeeid
where t.startdate != N'2012-01-01' OR t.enddate != N'2012-01-01'



In the above statement in WHERE clause change OR -> AND according to your requirement.
 
Share this answer
 
Hi, use below query

SQL
Select e.employeename 
from employee e join timesheet t 
where e.employeeid=t.employeeid
and (isnull(t.startdate,'') = '' 
or isnull(t.enddate,'') = '' )


Hopefully, It will solve your problem. :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900