philand3 (9/18/2016)
Hi,Yes this is sample.
Please ignore duplicate entries.
ok lets start again......here is some sample data that covers your possible permutation.....based on what I think I undestand so far.
if this is not correct, or there are other possibilites...please amend my code accordingly.
USE tempdb
GO
DROP TABLE IF EXISTS yourtable;
CREATE TABLE yourtable(
action_id INT NOT NULL
,creation_date DATETIME NOT NULL
,event_name VARCHAR(3) NOT NULL
,Emp_Num INT NOT NULL
,comments VARCHAR(25)
);
INSERT INTO yourtable(action_id,creation_date,event_name,Emp_Num,comments) VALUES
(1,'2016/07/21 10:37','IN',1,NULL)
,(2,'2016/07/21 11:37','OUT',1,NULL)
,(3,'2016/07/21 10:37','IN',2,'two entries on single day')
,(4,'2016/07/21 11:37','OUT',2,'two entries on single day')
,(5,'2016/07/21 15:37','IN',2,'two entries on single day')
,(6,'2016/07/21 16:37','OUT',2,'two entries on single day')
,(7,'2016/07/21 20:37','IN',3,'span over midnight')
,(8,'2016/07/22 02:37','OUT',3,'span over midnight')
,(9,'2016/07/21 10:37','IN',4,'span over days')
,(10,'2016/07/23 08:37','OUT',4,'span over days')
,(11,'2016/07/21 10:37','IN',5,'No OUT')
,(12,'2016/07/21 10:37','OUT',6,'No IN')
,(13,'2016/07/21 10:37','IN',7,'less than 1 hour')
,(14,'2016/07/21 10:47','OUT',7,'less than 1 hour');
SELECT * FROM yourtable
can I please ask you to provide a table of the results that you would expect for this sample data.....I mean by this actual figures, not just words explaining.
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day