By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

Help...

P: 5
I am using a SQL SERVER 2000...

My problem is that I would like to transfer my data in AttendanceLog Table To Attendance Table. Insert the first IN of the employee and first or last OUT of the employee. The EmpID should be non-occuring meaning only EmpID 1, 2, 3 will be transferred.

Conditions are the following:
1. Transfer the first login of the day and first/last logout of the day or the first logout next day.
2. Flexible Time - Render 9hrs or record the last logout.

I just want to transfer the all the logs from Table 1 to Table 2...

From AttendanceLog table

Date EmpID TransactionType DateTime
11/11/2008 1 IN 11/11/2008 8:00 AM // IN
11/11/2008 3 IN 11/11/2008 8:15 AM // IN
11/11/2008 2 IN 11/11/2008 8:30 AM // IN
11/11/2008 1 IN 11/11/2008 10:00 AM // Break
11/11/2008 1 IN 11/11/2008 12:01 PM // Lunch Break
11/11/2008 2 IN 11/11/2008 12:15 PM // Lunch Break
11/11/2008 3 IN 11/11/2008 1:30 PM // Lunch Break
11/11/2008 3 OUT 11/11/2008 5:30 PM // OUT
11/11/2008 4 IN 11/11/2008 5:35 PM // Night Shift
11/11/2008 1 OUT 11/11/2008 5:36 PM // OUT
11/11/2008 2 OUT 11/11/2008 5:38 PM //OUT
11/12/2008 4 OUT 11/12/2008 3:15 PM // OUT


TO Attendance Table

Date EmpID DateTimeIN DateTimeOut
11/11/2008 1 11/11/2008 8:00 AM 11/11/2008 5:36 PM
11/11/2008 2 11/11/2008 8:30 AM 11/11/2008 5:38 PM
11/11/2008 3 11/11/2008 8:15 AM 11/11/2008 5:30 PM
11/12/2008 4 11/11/2008 5:35 PM 11/12/2008 3:15 PM

Hope you would help me to implement this... I'm not good in sql
Nov 14 '08 #1
Share this Question
Share on Google+
1 Reply


Delerna
Expert 100+
P: 1,134
The solution will be something like this hint.

Expand|Select|Wrap|Line Numbers
  1. select [Date],EmpID,min(DateTime),max(DateTime)
  2. from AttendanceLog
  3. group by [Date],EmpID
  4.  
Nov 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.