I have query to find Records in to single records from two rows with First AttTime and Last AttTime using SQL Server 2005
My AttLog Table Structure is:
EnrollNo Int
AttDate DateTime
AttMonth Int
AttDay Int
AttYear Int
AttTime Varchar
Current output:
EnrollNo AttDate AttMonth AttDay AttYear AttTime
405 2011-03-09 09:59:00.000 9 3 2011 9:59
405 2011-03-09 18:40:00.000 9 3 2011 18:40
Desired output:
EnrollNo AttDate AttMonth AttDay AttYear FirstTime Last Time
405 2011-03-09 09:59:00.000 9 3 2011 9:59 18:40
Assuming you are grouping records with same EnrollNo, you should use aggregate functions