Header Ads Widget

Student Advisor | Hackerrank certification solution

 Student Advisor | Hackerrank certification solution:-

A university has started a student-advisor plan which assigns a professor as an advisor to each student for academic guidance. Write a query to find the roll number and names of students who either have a male advisor with a salary of more than 15,000 or a female advisor with a salary of more than 20,000.\

There are two tables in the database: student_information and faculty information. The primary key of student_information is roll number whereas that of faculty_information is employee_ID.

 Student Advisor | Hackerrank certification solution:-

 The objective of code is write a query to find the roll number and names of students who either have a male advisor with a salary of more than 15,000 or a female advisor with a salary of more than 20,000.

Schema :-


Sample Data :-




Sample output:

2 Claire

Explanation:

  • Student with roll number 2 is advised by a male teacher with a salary of 21,000 which is more than 15,000 and hence is displayed in the output.
  • Students 1 and 3 are advised by a female teacher whose salary is less than 20,000 and hence are not present in the output.

Mysql code:-

SELECT s.roll_number, s.name from student_information s INNER JOIN faculty_information
f on s.advisor=f.employee_id where (f.gender="M" and f.salary>15000) or
(f.gender="F" and f.salary>20000)

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-






Post a Comment

0 Comments