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
Why is it preferable to code web pages in HTML format?
balu736 [363]

Answer:

its c on plato

Explanation:

5 0
3 years ago
Explain why binary codes are used to represent characters, numbers and symbols :)
guajiro [1.7K]
Binary (base 2) is much easier to encode on a hard drive as it only has two states, whereas letters, numbers and symbols can be one of hundreds.
8 0
3 years ago
Read 2 more answers
Why did England establish the Sugar Act?
Iteru [2.4K]

Answer:

The Revenue Act of 1764, also known as the Sugar Act, was the first tax on the American colonies imposed by the British Parliament. Its purpose was to raise revenue through the colonial customs service and to give customs agents more power and latitude with respect to executing seizures and enforcing customs law.

Explanation:

Hope this helps- Good luck ^w

4 0
3 years ago
Why is it pointless to expect cyberattackers to follow organizational legal measures?
WITCHER [35]

Answer:

The answer is A.

5 0
3 years ago
To apply the rule of thirds you first? PLZ HURRY AND ANSWER THIS
Deffense [45]
B/ Divide the viewpoint into three equal vertical divisions
5 0
4 years ago
Read 2 more answers
Other questions:
  • (Financial application: compound value) Suppose you save $100 each month into savings account with an annual interest rate of 5%
    6·1 answer
  • Consolidating a system's physical and time resources is known as ________________.
    13·1 answer
  • The Warn-on-Forecast has been developed by the National Weather Service to help predict hazardous weather earlier. Which of the
    10·2 answers
  • Code
    7·1 answer
  • What is nominal data?
    5·1 answer
  • Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
    15·1 answer
  • Versiones del Moodle
    10·1 answer
  • Answer if you know Javascript, html, css, python, and Ruby.
    12·1 answer
  • Identify the programmer’s responsibility in maximizing the programs reliability by having awareness of the beneficial and harmfu
    8·1 answer
  • What is the factor of 200
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!