I have a database and it manages student data. I would like to find top most values across fields. Fields are subjectsand I have to use two highest values to find a certain
value. I have used a code to define maximum function but this works only in finding top most, how can i adjust it to find the next highest or next two highest.
This would be a lot easier if your database was properly normalized. Notice the bolded portion above. That is not the right way to design this. You should have at least three tables;
Students: info identifying each student
Subjects: a listing of each subject
StudentSubjects: a record for each student and the scores for each subject. (If a student had 3 subjects there would be 3 records)
With this structure it would be very easy to sort scores within each student.
I suggest you look at redesigning your database.