Pergunta de entrevista da empresa Electronic Arts

SQL question Assume data base with students Table with students final grades Name - Subject - Grade 1 Find the top 3 ranks. 2 Find top 3 subject wise 3 Find top 3 grade wise

Resposta da entrevista

Sigiloso

11 de mai. de 2015

1. SELECT TOP 3 * FROM Students ORDER BY Grade DESC; 2.Think of it as, Select * from each subject where the grade is no less than the second highest SELECT S.* FROM Students as S WHERE ( SELECT COUNT(*) FROM Students as X Where S.Subject=X.Subject AND S.Grade>=X.Grade)<=2 ORDER BY S.Subject; 3. Similar to above.

1