Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select USER_ID, User_FirstName+ ' ' + User_LastName as [Last Name] , NULL as InTime, NULL as OutTime
FROM access_user
WHERE user_automatch='1' and user_id not in  --not exists "
(select  distinct e.userid as [user_id]
from access_event_logs As E
where  Convert(date,LOCALTIMESTAMP) between '03-24-2014' and '03-24-2014'
and (EVENTID ='In' or EVENTID='Out'))

Union

select distinct
E.USERID, U.User_FirstName+ ' ' + U.User_LastName as [Last name],
(select min(Convert(TIME,LOCALTIMESTAMP)) from access_event_logs As MINCE where CAST(MINCE.LOCALTIMESTAMP as DATE)=CAST(E.LOCALTIMESTAMP As DATE) AND MINCE.EVENTID ='In' and MINCE.USERID=E.USERID) as InTime,
(select max(Convert(TIME,LOCALTIMESTAMP)) from access_event_logs As MAXCE where CAST(MAXCE.LOCALTIMESTAMP as DATE)=CAST(E.LOCALTIMESTAMP As DATE) AND MAXCE.EVENTID ='Out' and MAXCE.USERID=E.USERID) as OutTime
from access_event_logs As E
Inner join access_user as U on E.USERID = U.User_ID
WHERE   Convert(date,LOCALTIMESTAMP) between '03-24-2014' and '03-24-2014'
Order by User_ID


this query working fine, but select above 2days show report userid id only one day abesent showing null value....

1month absent showing that userid only one row....

how to set this problem.....
Posted
Updated 27-May-14 23:12pm
v2
Comments
Chaitanya Pai 29-May-14 0:28am    
Hi,
Just execute one by one query from inner to outer and check if any of the query returning no values.
akhil.krish 29-May-14 5:36am    
outer join not working....

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