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 |
forwheeler
Starting Member
44 Posts |
Posted - 2007-11-27 : 09:23:17
|
SELECT ClassInstructor.ClassID, Date.StartDateTime, Date.EndDateTimeFROM Instructor INNER JOIN ClassInstructor ON Instructor.InstructorID = ClassInstructor.InstructorID INNER JOIN ClassDate ON ClassInstructor.ClassID = ClassDate.ClassIDINNER JOIN Date ON ClassDate.DateID = Date.DateID WHERE (Instructor.InstructorID = @InstructorID) The result is 4 2007-09-04 12:00:00 2007-09-04 16:00:0021 2007-10-02 00:00:00 2007-10-02 00:00:0021 2007-10-10 00:00:00 2007-10-10 12:00:00I only want one StartDateTime and EndDateTime for each class, not the other times for a given class.What is the easiest way to do this? |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-27 : 09:41:52
|
SELECT ClassInstructor.ClassID, min(Date.StartDateTime) as StartDateTime, min(Date.EndDateTime) as EndDateTimeFROM Instructor INNER JOIN ClassInstructor ON Instructor.InstructorID = ClassInstructor.InstructorID INNER JOIN ClassDate ON ClassInstructor.ClassID = ClassDate.ClassIDINNER JOIN Date ON ClassDate.DateID = Date.DateID WHERE (Instructor.InstructorID = @InstructorID)GROUP BY ClassInstructor.ClassIDMadhivananFailing to plan is Planning to fail |
 |
|
forwheeler
Starting Member
44 Posts |
Posted - 2007-11-27 : 09:46:29
|
Perfect!Thanksquote: Originally posted by madhivanan SELECT ClassInstructor.ClassID, min(Date.StartDateTime) as StartDateTime, min(Date.EndDateTime) as EndDateTimeFROM Instructor INNER JOIN ClassInstructor ON Instructor.InstructorID = ClassInstructor.InstructorID INNER JOIN ClassDate ON ClassInstructor.ClassID = ClassDate.ClassIDINNER JOIN Date ON ClassDate.DateID = Date.DateID WHERE (Instructor.InstructorID = @InstructorID)GROUP BY ClassInstructor.ClassIDMadhivananFailing to plan is Planning to fail
|
 |
|
|
|
|