Top Competitors in SQL | HackerRank Programming Solutions | HackerRank SQL Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language SQL. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Top Competitors in SQL-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To SQL

SQL stands for Structured Query Language. SQL is used to create, remove, alter the database and database objects in a database management system and to store, retrieve, update the data in a database. SQL is a standard language for creating, accessing, manipulating database management system. SQL works for all modern relational database management systems, like SQL Server, Oracle, MySQL, etc.

  • It is a standard language for Relational Database System. It enables a user to create, read, update and delete relational databases and tables.
  • All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their standard database language.
  • SQL allows users to query the database in a number of ways, using English-like statements.

Link for the ProblemTop Competitors SQL – Hacker Rank Solution

Top Competitors SQL – Hacker Rank Solution


Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.

Input Format

The following tables contain contest data:

  • Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.
  •  1458526776 67667350b4 ScreenShot2016 03 21at7.45.59AM
  • Difficulty: The difficult_level is the level of difficulty of the challenge, and score is the score of the challenge for the difficulty level.
  •  1458526915 57eb75d9a2 ScreenShot2016 03 21at7.46.09AM
  • Challenges: The challenge_id is the id of the challenge, the hacker_id is the id of the hacker who created the challenge, and difficulty_level is the level of difficulty of the challenge. 1458527032 f9ca650442 ScreenShot2016 03 21at7.46.17AM
  • Submissions: The submission_id is the id of the submission, hacker_id is the id of the hacker who made the submission, challenge_id is the id of the challenge that the submission belongs to, and score is the score of the submission.
  •  1458527077 298f8e922a ScreenShot2016 03 21at7.46.29AM

Sample Input

Hackers Table: 1458527241 6922b4ad87 ScreenShot2016 03 21at7.47.02AM Difficulty Table: 1458527265 7ad6852a13 ScreenShot2016 03 21at7.46.50AM Challenges Table: 1458527285 01e95eb6ec ScreenShot2016 03 21at7.46.40AM Submissions Table: 1458527812 479a74b99f ScreenShot2016 03 21at8.06.05AM

Sample Output

90411 Joe


Hacker 86870 got a score of 30 for challenge 71055 with a difficulty level of 2, so 86870 earned a full score for this challenge.

Hacker 90411 got a score of 30 for challenge 71055 with a difficulty level of 2, so 90411 earned a full score for this challenge.

Hacker 90411 got a score of 100 for challenge 66730 with a difficulty level of 6, so 90411 earned a full score for this challenge.

Only hacker 90411 managed to earn a full score for more than one challenge, so we print the their hacker_id and name as  space-separated values.

Top Competitors SQL – Hacker Rank Solution
select Hackers.hacker_id, from Hackers
join Submissions
on Hackers.hacker_id = submissions.hacker_id
join Challenges
on Challenges.challenge_id = Submissions.challenge_id
join Difficulty
on Difficulty.difficulty_level = Challenges.difficulty_level
where Submissions.score = Difficulty.score
group by Hackers.hacker_id, having count(*)>1
order by count(*) DESC,Hackers.hacker_id;
30 July 2020 at 02:10

Leave a Comment

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.