Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
tpratyush
Starting Member
17 Posts |
Posted - 2013-09-30 : 03:39:24
|
Input ID Emp No. Start Date End Date Pattern1234 5678 3/5/2010 3/6/2010 A11234 5678 3/5/2010 3/6/2010 B11234 5678 3/7/2010 3/8/2010 A11234 5678 3/7/2010 3/8/2010 B11234 5678 3/9/2010 3/10/2010 A11234 5678 3/9/2010 3/10/2010 B11234 5678 3/11/2010 3/12/2010 A11234 5678 3/11/2010 3/12/2010 B11234 5678 3/13/2010 3/14/2010 A11234 5678 3/13/2010 3/14/2010 B11234 5678 3/15/2010 3/16/2010 A11234 5678 3/15/2010 3/16/2010 B1Output ID Emp No. Authorized Start Date Authorized End date Pattern1234 5678 3/5/2010 3/16/2010 A11234 5678 3/5/2010 3/16/2010 B1In the input table, the Pattern are present as A1, B1. I need the output as showed. The latest end date will be the Auth. End date similarly, the earliest start date will be the Auth. Start Date.Thanks and Regards,Pratyush Tripathy |
|
VasiAnu
Starting Member
9 Posts |
Posted - 2013-09-30 : 05:46:04
|
elect DISTINCT ID,EmpNo,MIN(StartDate) StartDate ,MAX(EndDate) EndDate,Pattern from TableNameGroup by ID,EmpNo,PatternThanks,VA. |
|
|
|
|
|