Monday, November 3, 2014

Join three tables not getting all the data from the main table

Hi Jonathan,


Thanks for that. I ran the query with your suggested changes, but still only 26761 rows returned.


If I run this query on just the StudentBookingDetails table:



SELECT StudentId,ClassId,StartDate,StudentName,ClassTypeId,ClassStartDate,LevelID,LessonLevel,ClassType
FROM StudentBookingDetails
WHERE (StartDate >= CONVERT(DATETIME, '2014-01-01 00:00:00', 102))

I get 53262 rows.


If I run this query, which has the Location columns and join removed and the StudentBookingDetails on the left as you suggest:



SELECT StudentBookingDetails.ClassId, StudentBookingDetails.ClassType, StudentBookingDetails.ClassStartDate, Class_Details.LessonLevel, Class_Details.LocationId,
StudentBookingDetails.StudentId, StudentBookingDetails.StudentName
FROM StudentBookingDetails LEFT OUTER JOIN
Class_Details ON StudentBookingDetails.ClassId = Class_Details.ClassId
WHERE (StudentBookingDetails.ClassStartDate >= CONVERT(DATETIME, '2014-01-01 00:00:00', 102))

I still only get 26761.


Got me stumped!




Mark


No comments:

Post a Comment