Hi all,I have the following scenario that is the key of my big problemI have for example the following table:CREATE TABLE [classes_grade]( [CLASS_NAME] [nvarchar](10) NOT NULL, [STUDENT_NAME] [nvarchar](10) NOT NULL, [COURSE_NAME] [nvarchar](10) NULL, [GRADE] [int] NULL, [DATE] [datetime] NULL, )
I want to get the highest grade in each class in the results and i have to return the class_name, student_name, grade and date cloumnsI did the following query but seems not working. It returns more than one record for each class.SELECT lq.CLASS_NAME, lq.STUDENT_NAME, lq.GRADE, lq.DATE FROM classes_grade lq WITH(NOLOCK) WHERE lq.GRADE in( SELECT Max(t.watch_timestamp) FROM classes_grade as t WITH(NOLOCK) group by t.CLASS_NAME )
I'll be gratefull for any reply and suggestion!!