Answered Questions

  • Sql query to obtain 2nd highest mark in each subject for a student

    Given a table with 3 columns StudentName,Subject and Marks.Write a sql to retrieve second highest Marks Obtained for each student.

    Zienab

    • Mar 26th, 2022

    Select Z.first_name, Z.last_name, Z.salary From (SELECT EMP.first_name, EMP.last_name, EMP.salary, RANK() OVER( Order by EMP.salary DESC) as Ranking FROM employees EMP ) Z Where Z.Ranking = 2;

    Code
    1.  

    Rachana J K

    • Jan 10th, 2022

    Select student_name, marks from Student order by marks desc limit(2,1) group by sub-name;