
SQL query help -
- or -
Post a project like this3597
$10
- Posted:
- Proposals: 2
- Remote
- #876531
- Awarded
Description
Experience Level: Intermediate
Estimated project duration: 1 day or less
General information for the website: SQL server query for in n out time in an interval within 24 hours
Database management system (DBMS): Microsoft SQL Server
Description of requirements/features: Hi,
i have table with a field as ID , dateTime for time clock. depend on the day partition divide by 2. In and Out i making employee attadance. that is wokring perfectly.
But EMPLOYEE MISSED PUNCHs.. TAKE NEXT DAY AS OUT PUNCH. so i need with 23 hours time interval value is issing should take as null value as OUT.
Please find the query.. need to modify the 23 hours internale as OUT punch. else null as out punch.
SELECT p.empno , p.punch_time , CASE (row_number() over (partition by empno
order by p.punch_time asc)% 2)
WHEN 1 THEN 'IN'
ELSE 'OUT'
END AS punch_type
FROM (SELECT f1 empno,f2 punch_time FROM [dbo].['20150818'] where CAST(f1 AS INTEGER)='40042') p
Please find the expected image for the same.
Thanks a lot in advance.
Extra notes:
Database management system (DBMS): Microsoft SQL Server
Description of requirements/features: Hi,
i have table with a field as ID , dateTime for time clock. depend on the day partition divide by 2. In and Out i making employee attadance. that is wokring perfectly.
But EMPLOYEE MISSED PUNCHs.. TAKE NEXT DAY AS OUT PUNCH. so i need with 23 hours time interval value is issing should take as null value as OUT.
Please find the query.. need to modify the 23 hours internale as OUT punch. else null as out punch.
SELECT p.empno , p.punch_time , CASE (row_number() over (partition by empno
order by p.punch_time asc)% 2)
WHEN 1 THEN 'IN'
ELSE 'OUT'
END AS punch_type
FROM (SELECT f1 empno,f2 punch_time FROM [dbo].['20150818'] where CAST(f1 AS INTEGER)='40042') p
Please find the expected image for the same.
Thanks a lot in advance.
Extra notes:

Dod it S.
100% (31)Projects Completed
43
Freelancers worked with
32
Projects awarded
35%
Last project
1 Apr 2021
India
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies