I need a query for getting the 2nd highest marks from a table.

G

Guest

I have a table "Student" consists of two fields "Name" & "Marks". I want to
write a query for getting the 2nd highest marks obtain by student from the
table.
 
G

Guest

You could paste the following into the SQL view of the query window:

SELECT Max(Student.Marks) AS Expr1
FROM Student
WHERE (((Student.Marks) Not In (select Max(Student.Marks) from Student)));

To do it using the query grid, add the Student table,
Enter "Expr1: Max(Student.Marks)" (but no quotes) into the Field row of the
first column
Enter "Marks" into the Field row and "Student" into the table row, and "Not
In (select max(Student.Marks) from Student)" into the Criteria row of the
second column (no quotes around these, either)

Run the query
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top