I had the phone interview with a senior BIE today in which I was asked below sql question-
Write a SQL query to calculate total time spent by each employee on each day at office-
CREATE TABLE Employee
(
[empid] int,
[Time] DATETIME,
[In_Out] VARCHAR(3)
);
INSERT Employee
VALUES
(1, '2019-01-01 09:00:00', 'In'),
(2, '2019-01-01 12:00:00', 'Out'),
(1, '2019-01-01 13:00:00', 'In'),
(2, '2019-01-01 17:00:00', 'Out'),
(2, '2019-01-02 23:00:00', 'In'),
(3, '2019-01-03 07:00:00', 'Out');
Below is the interview process of BIE (which may differ slightly in some cases) -