Hello coders, In this post, you will learn how to solve the Ollivander’s Inventory SQL Hacker Rank Solution. This problem is a part of the SQL Hacker Rank series.
As you already know that this site does not contain only the Hacker Rank solutions here, you can also find the solution for other problems. I.e. Web Technology, Data Structures, RDBMS Programs, Java Programs Solutions, Fiverr Skills Test answers, Google Course Answers, Linkedin Assessment, and Coursera Quiz Answers.
Harry Potter and his friends are at Ollivander’s with Ron, finally replacing Charlie’s old broken wand.
Hermione decides the best way to choose is by determining the minimum number of gold galleons needed to buy each non-evil wand of high power and age. Write a query to print the id, age, coins_needed, and power of the wands that Ron’s interested in, sorted in order of descending power. If more than one wand has same power, sort the result in order of descending age.
The following tables contain data on the wands in Ollivander’s inventory:
- Wands: The id is the id of the wand, code is the code of the wand, coins_needed is the total number of gold galleons needed to buy the wand, and power denotes the quality of the wand (the higher the power, the better the wand is).
- Wands_Property: The code is the code of the wand, age is the age of the wand, and is_evil denotes whether the wand is good for the dark arts. If the value of is_evil is 0, it means that the wand is not evil. The mapping between code and age is one-one, meaning that if there are two pairs, and , then and .
Wands Table: Wands_Property Table:
9 45 1647 10 12 17 9897 10 1 20 3688 8 15 40 6018 7 19 20 7651 6 11 40 7587 5 10 20 504 5 18 40 3312 3 20 17 5689 3 5 45 6020 2 14 40 5408 1
Ollivander’s Inventory SQL – Hacker Rank Solution
SELECT a.id, b.age, a.coins_needed, a.power FROM wands a JOIN wands_property b ON a.code = b.code WHERE b.is_evil = 0 AND a.coins_needed = (SELECT Min(a1.coins_needed) FROM wands a1 JOIN wands_property b1 ON a1.code = b1.code WHERE b.age = b1.age AND a.power = a1.power) ORDER BY a.power DESC, b.age DESC;
Disclaimer: The above Problem (Ollivander’s Inventory) generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.
Is HackerRank good for SQL practice?
You’ve probably heard of HackerRank before, so it should be no surprise to you that they have one of the best collections of SQL practice challenges around.
Which SQL does HackerRank use?
The HackerRank Test interface has an in-built database query editor and supports programming in Microsoft SQL, MySQL, Oracle, or DB2 databases.
What is HackerRank SQL?
Basic. Get Certificate. SQL is an industry-standard query language that works with relational databases. Unlike some earlier systems, queries are performed at the server and only the results are passed to a client. This resulted in the ability to work with large databases efficiently over a network.
How many questions are there in HackerRank for SQL?
That will also help your SQL code challenges journey
It took me a bit more than two weeks (on and off between work, workout, and taking the kid to day school, etc.) to finish all the 58 SQL challenges on the site, and I gained quite some insights from the journey (and having quite some fun doing that!).
Where can I find HackerRank solutions in SQL?
in this post, you will get all the solutions of HackerRank SQL Problems.
Finally, we are now, in the end, I just want to conclude some important message for you
Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.
Please share our posts on social media platforms and also suggest to your friends to Join Our Groups. Don’t forget to subscribe.
We Have Covered Hackerrank SQL all question answers :
hackerrank,hackerrank sql solutions,hackerrank sql,hackerrank solutions,hackerrank solution,sql solution,revising the select query in hackerrank solution,sql solutions hackerrank,hacker rank solutins of sql,hackerrank certificate solutions,select all hackerrank solution,hackerrank the pads solution in hindi,weather observation station 3 hackerrank solution,weather observation station 4 hackerrank solution,weather observation station 7 hackerrank solution