1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klemol [59]
3 years ago
11

Harry Potter and his friends are at Ollivander's with Ron, finally replacing Charlie's old broken wand. Hermione decides the bes

t 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.
Computers and Technology
1 answer:
Step2247 [10]3 years ago
4 0

Answer:

SELECT a.id, ab.age, b.min_coins_needed, b.power

FROM(SELECT code, power, min(coins_needed) AS min_coins_needed

 from Wands

 group by power, code) AS b

JOIN Wands wa

 ON a.coins_needed = b.min_coins_needed AND a.code = b.code AND a.power = b.power

JOIN Wands_property AS ab  

 ON a.code = ab.code  

WHERE ab.is_evil = 0          

ORDER BY b.power desc, ab.age DESC;              

Explanation:  

SELECT statement is used to select the columns id, age, coins_needed and power of the wands that Ron's interested in.

It is required to get the minimum coins_needed so, min() aggregate function is used to return the minimum value of coins_needed. So this is how minimum coins needed for wands with same age and power are attained and the resultant set is given the name of min_coins_needed  using alias. This is then grouped by code and power using GROUP BY because code and age has one to one mapping.

Next the JOIN is used to combine columns from two or more relations. Here Wands and Wands_property are joined to obtain id and age.

WHERE clause is used to filter the wands that are not evil.

ORDERED BY is used to sort in order of power and age, the result obtained. DESC is used to sort the result in descending order of power and age.

You might be interested in
Select the correct answer from the drop-down menu. Which two technologies support the building of single-page applications? and
Nataliya [291]

Answer:

JavaScript frameworks and Ajax

Explanation:

6 0
4 years ago
Which is an appropriate strategy for using a workplace blog?
OLEGan [10]

Answer:

a

Explanation:

8 0
3 years ago
AYUDAAA ESPARA HOYYY
DIA [1.3K]

Answer:

what?

Explanation:

8 0
3 years ago
Read 2 more answers
Create a python program that display this
aleksley [76]

Answer:

vxxgxfufjdfhgffghgfghgffh

4 0
3 years ago
Is sonic better than piranha plant
nevsk [136]

Yes, well, in my opinion at least, Sonic will always be better than Piranha Plant.

7 0
4 years ago
Read 2 more answers
Other questions:
  • "The effectiveness of memory retrieval is directly related to the similarity of cues present when the memory was encoded to the
    11·1 answer
  • -Give a definition of the critical section problem and explain the purpose of the entry and exit code blocks
    13·1 answer
  • 7.3 A hydraulic lift has a mechanical advantage of 6. If the load weighs 780 N, calculate
    13·1 answer
  • I need them on this question
    5·1 answer
  • Please help me on this please i am giving all of my points so please help me
    6·1 answer
  • What is the widest area network?
    15·1 answer
  • Question #3
    15·2 answers
  • Spark is electrical discharge in air, while air is mix of variety of gases what particles conduct electricity in gas
    12·1 answer
  • 2. Write the pseudocode to print all multiples of 5 between 10 and 25 (including both<br> 10 and 25)
    11·1 answer
  • You work with alot of different documents in your internship with a software development company. What kinds of actions can you
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!