Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I m using a SQL Server database with a table names Attendence. The columns in the table are:

1) EmpCode int
2) AttendenceDate datetime
3) AttendenceTime Datetime
4) Status tinyint

Data in the table would be like this:

SQL
Code AttendenceDate AttendenceTime status
1001 3/27/2009      3/27/2009 9:05 1
1001 3/27/2009      3/27/2009 7:05 0


1003 3/29/2009      3/27/2009 7:05 1
1003 3/29/2009      3/27/2009 7:05 0
1001 3/30/2009      3/27/2009 7:05 1
1001 3/30/2009      3/27/2009 7:05 0


A value of "1" for Status means check-in and "0" means check-out. I need a query to show the results like this:

Code date      Timein Timeout
1001 3/27/2009 9:05   7:05


How can I make the perfect query for this?

Thanks in advance.
Posted
Updated 31-Mar-10 10:12am
v5

I think your database design is wrong. If you use the folowing columns, you will have no problems with your query, and the table will take less diskspace:

EmpCode int
AttendenceDate smalldatetime
TimeIn SmallDateTime
TimeOut SmallDateTime
 
Share this answer
 
And you expect to get an answer, or better answer, by reposting the same question?
 
Share this answer
 

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