499 views

1 Answer

Best answer
5 votes
5 votes

It is giving name of student who secured 3rd rank among all.

Here are two columns "Name" and "marks" in the table. and "Count" column is just for explanation.

Name Marks Count
A 50 5
B 78 3
C 82 2
D 99 1
E 74 4

Here same table is referenced two times. S1 is for outer query and S2 for inner query. and both are co-related subqueries. Hence for each S1 we need to check all S2.

S1 = A,50 then count = 5 (Because 50 is lesser or equal to all given marks.)

S1 = B,78 then count = 3 (because 78 is lesser or equal to 78,82,99)

S1 = C,82 then count = 2 (because 82 is lesser or equal to 82,99)

S1 = D,99 then count = 1 (because nothing is lesser than 99 only it is equal to itself in S2.marks)

S1 = E,74 then count = 4 (because 74 is lesser or equal to 74,78,82,99)

Hence we have to choose name of count =3 Which giving name of student who secured 3rd rank.

selected by

Related questions

1 votes
1 votes
1 answer
1
Harikesh Kumar asked Jan 13, 2018
395 views
Provide the correct answer
1 votes
1 votes
1 answer
4
khushtak asked Jan 20, 2016
822 views
Can anyone suggest me how to learn about sql and relational algebra and calculus for gate?as i feel this is an important topic and one 2 marks ques will be asked. I can u...