I have student marks in a student table. I need second
highest mark .Then what will the query for this?

Answer Posted / devi

Get data to internal table from database table using select query.
Sort the second internal table by ascending order.
Then use Delete adjacent duplicates comparing highest marks.
It will remove duplicate highest marks.
Then sort the internal table by descending order.
Read internal table into workarea index 2.
It will give the second highest mark.

Some times we have to process more steps using all data's. At that time we have to create two internal table with same structure . Move the data from firs table to second table and do the above steps.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to sort the query output with order by clauses in ms sql server?

644


Write a sql query to delete duplicate records from a table called table1

596


Explain the architecture of ms sql reporting service?

538


Can a unique index be created on a column, which contains null?

533


What is sql server used for?

562






What is lookup override?

594


What is difference between getdate and sysdatetime in sql server 2008?

612


What does it mean to invest in the index?

519


Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?

106


Is truncate autocommit?

570


Find columns used in stored procedure?

536


How to rebuild indexes with alter index ... Rebuild?

600


What is the difference between insensitive and scroll cursor?

589


Explain the steps to use transact-sql cursor?

530


What is ssrs?

99