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 |
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2010-10-26 : 12:07:02
|
| I'm using SQL 2005 and I wrote the following Query. I can get parts of it to run, but when I run the entire query with the sub query the query will not complete. I'm including table names and column names. Does anyone have any ideas what I could do to get this script to execute?dbo.AdEnrollSyStudentIDStartDateGradDatedbo.AdEnrollSchedADEnrollIDSyStudentIDStartDatedbo.AdEnrollDegreeAdEnrollIDAdDegreeIDDateAwardedSELECT DISTINCT TOP (100) PERCENT dbo.syStudent.SyStudentId, dbo.AdEnroll.GradDate, dbo.AdEnrollDegree.DateAwarded, dbo.syStudent.LastName, dbo.syStudent.FirstName, dbo.AdEnrollSched.ExpectedEndDateFROM dbo.AdEnrollSched RIGHT OUTER JOIN dbo.AdEnroll ON dbo.AdEnrollSched.AdEnrollID = dbo.AdEnroll.AdEnrollID LEFT OUTER JOIN dbo.AdEnrollDegree ON dbo.AdEnroll.GradDate = dbo.AdEnrollDegree.DateAwarded RIGHT OUTER JOIN dbo.syStudent ON dbo.AdEnroll.SyStudentID = dbo.syStudent.SyStudentIdWHERE (dbo.syStudent.LastName = 'Smith') AND (dbo.syStudent.FirstName = 'John') AND (NOT (dbo.AdEnrollSched.ExpectedEndDate IS NULL))(Select LastName,FirstName,AdEnrollId,Max(ExpectedEndDate) AS MaxDateFROM dbo.AdEnrollSched,dbo.SyStudentGroup ByLastName, FirstName, AdEnrollID, ExpectedEndDate)ORDER BY dbo.AdEnrollSched.ExpectedEndDate, dbo.syStudent.LastName |
|
|
namman
Constraint Violating Yak Guru
285 Posts |
Posted - 2010-10-26 : 15:38:03
|
| Could you provide sample data of the tables and expected output? |
 |
|
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2010-10-27 : 09:18:47
|
| It's a comparison of the end date of the last class ExpectedEndDate to the graduation date which is DateAwarded. I also only want the MAX date for the ExpectedEndDate per person. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|