I have student marks in a student table. I need second
highest mark .Then what will the query for this?
Answers were Sorted based on User's Feedback
Answer / jyoti bikash panda
select a.marks from student a where(select count(b.marks)
from student b where a.marks<=b.marks)=2
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / dinesh gupta
4th highest salary
SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY
grosssalary desc) AS salaryno , *
FROM (
select distinct grosssalary
from salarydetails where inmon='dec' and inyear = 2007
) as a
) As T
WHERE t.salaryno = 4
3rd lowest salary
SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY
grosssalary ) AS salaryno , *
FROM (
select distinct grosssalary
from salarydetails where inmon='dec' and inyear = 2007
) as a
) As T
WHERE t.salaryno = 3
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / aaaa
SELECT * FROM `student` WHERE class='Six' ORDER BY mark DESC
LIMIT 1,1
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / vikas kant
select Top 1 marks from students where marks in(select Top
2 marks from students order by marks desc)
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / appalanaidu
select max(marks) from studentmaster where marks < (select max(marks) from studentmaster)
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / dolat ram
select max(mark) from student where mark < (select max
(mark) from student)
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sarika
select max(mark)
from student
Having max(mark)<(select max(mark)
from student)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / maheswar reddy s
select top 1 * from (select top 2 marks from student order by marks desc)a order by marks
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
Answer / ahmed
SELECT TOP 1 student marks
FROM(
SELECT TOP 2 student marks
FROM students_table
ORDER BY student marks DESC) AS emp
ORDER BY student marks ASC;
| Is This Answer Correct ? | 0 Yes | 0 No |
How to store pdf file in sql server?
1 Answers CarrizalSoft Technologies, College School Exams Tests, TATA,
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?
write coding for importing sql data into a word excel...
How do you find the error, how can you know the number of rows effected by last SQL statement?
What is difference between rownum and row_number?
How will you find out if there are expensive SQL statements running or not?
Name 3 ways to get an accurate count of the number of records in a table?
What is a cursor, index in sql?
How to optimize stored procedure optimization?
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?
What kind of problems occurs if we do not implement proper locking strategy?
The external application that is executed in one of the tasks does not have a log file, but only a screen log. How can I save the data from the screen? : sql server management studio
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)