Hi i want need to fetch sec highest marks from given tables.
my database design is like:
My database design:
Table 1:
Student table
(PK)Stud_id, Stud_name
Table 2:
Subject table
(pk)Sub_id, Sub_name, Marks.
Table 3:
Stud_Sub table
Stud_id, Sub_id
And i come up with the query:
Select Student.stud_id, Student.stud_name Max( subject.marks)from Student, subject, stud_sub
where marks < ( Select Max(sum(marks)) from student, subject, stud_sub where student.stud_id = stud_sub.stud_id AND stud_sub.sub_id = Subject.sub_id group by stud_id;
Can any one correct me, if this query is wrong coz m new in query writing.
please help me in finding the second highest marks in database.