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 / vk
select studentid,student_name,marks from
(select row_number() over (partition by marks order by marks desc) as rnk,studentid,student_name,marks from student_marks)
where studentid in (1,4);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / lokeshwaran s
SELECT MAX(marks) AS second_highest_mark
FROM student
WHERE marks < (SELECT MAX(marks) FROM student);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / koti,khammam
select max(mark) from student where mark not in (select max
(mark) from student)
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / poomanibe
with temptab as
(
select row_number() over(order by substring(marks,1,2)) as
rownum,* from Student
)
select * from temptab where rownum=1
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / dharmendra k. dixit
SELECT TOP 1 Marks (SELECT TOP 2 Marks from Tablename Order
by Marks Desc)From Tablename order by Marks Asc
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / rupa
Select max(Marks) from Marks where Marks <
(select max(Marks)from Marks)
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / sagesh
SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY mark) AS Stu_Rank
FROM student) As T
WHERE Stu_Rank = 2
Is This Answer Correct ? | 2 Yes | 5 No |
I am using SQL Server 2005, I have some select and update statements in my query with WHERE clause I want to prevent these queries from SQL injection attacks. What are the steps and precautions to be taken for SQL Injection attacks? Does anybody have suggestions? Thanks in advance,
Delete duplicate rows from a table without primary key by using a single query Table Employee empname salary A 200 B 300 A 200 C 400 D 500 D 500 Output should be A 200 B 300 C 400 D 500
What is the difference between a unique key and primary key?
Hi Can any one tell me the Good institute to learn SQL esp for Data Base Testing or SQL from scratch to the proficiency level in Hyederabad and facult also. Thankyou well in advance
your distribution database is full what will u do
Can we join two tables without primary key?
Explain microsoft sql server functions?
How to transfer a table from one schema to another?
logshipping is Any difference 2000 and 2005?
What is a derived table?
What are orphan records?
What is a dbms wizard?