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
Which of the following would be considered a subtopic for a mind map?
Grace [21]

Answer:

C) Plants

Explanation:

"Ecosystem" is the topic. Then "Plants" is the sub topic. Next the "Number of trees" and "Number of shrubs" branch out from there (Pun intended (; ).

4 0
3 years ago
A small program that sends itself to other computers, rather than relying on user actions, is a
PSYCHO15rus [73]

Virus.

A virus is a malicious program or script that Spreads. 

Malware, however, will not spread. 

Viruses can spread without a victim's permission because it is automated to do so. 

For example, the Melissa virus would look like a file attachment that used reverse psychology to make you open it. From there, it goes through the first 50 email contacts stored on your computer and sends the virus to them from your computer. 
8 0
3 years ago
I have an IPhone 8plus 64gb... should I get another phone like samsung note 9 or s9 ??
laiz [17]

Nah, I think the IPhone would be better than them both


7 0
3 years ago
1. Withdrawal occurs when alcohol is removed from the system after the brain has
Westkost [7]
Experienced it for an extended period of time.
4 0
3 years ago
A student should be most cautious using a web address ending in
Inessa [10]

Answer:

It is .com because all the others are school-safe. And .com is snatch-able.

Explanation:

4 0
3 years ago
Other questions:
  • If you purchase a software suite for personal use, you can install the software how many times on how many different machines?
    6·1 answer
  • Find a, b, and c<br> A a=4 square root of 6 b= 8 square root of 2 ; c= 4 square root of 2
    12·1 answer
  • Josie, your best friend, is having a huge Sweet Sixteen party. She has designated you to address all 100 of the envelopes (using
    7·1 answer
  • Smartart and shapes are useful tools because they allow you to
    10·1 answer
  • Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
    11·1 answer
  • What is virtualization?
    11·2 answers
  • Microsoft vs Sony who wins ​
    13·2 answers
  • Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to the power of z), the absolut
    12·1 answer
  • Who watches the show gravity falls, if you do, if you play the theme song for the first episode backwards you get a hiding messi
    11·2 answers
  • What would be the best tool to display the following information from a basketball game?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!