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
When you use the tilde operator (~ in a url for the attribute of a server control, it represents the _____ directory of the webs
Verizon [17]
The tilde operator represents the root directory of the website.
4 0
3 years ago
____ is a style of programming that focuses on the step-by-step sequence of instructions and operations.
mario62 [17]

Answer: Algorithm

Explanation: An algorithm is a plan, a set of step-by-step instructions to solve a problem. it involves three basic building blocks to use when designing algorithms. these are.,

1. Sequencing

2. Selection

3. Iteration

7 0
3 years ago
Read 2 more answers
A non technical kind of cyber intrusion that relies heavily on human interaction and often involve tricking people into breaking
lana66690 [7]
Social Engineering.

---------------------------
4 0
3 years ago
Which tool do web designers use to select colors that complement each other?
DaniilM [7]
•color pick eye dropper chrome extension
•color snapper2
•happy hues
•coolors
3 0
2 years ago
This is an example of what kind of circuit? *
EleoNora [17]

Answer:

Series Circuit

Explanation:

A <em>series circuit</em> is a connection configuration in which the terminals or terminals of the devices (generators, resistors, capacitors, inductors, switches,  light buls, among others) are connected successively, that is, the output terminal of a device is connected to the input terminal of the next device.

.

8 0
3 years ago
Other questions:
  • Use ________ resolution when recording human speech in an audio file.
    14·1 answer
  • A ________ is a set of programs that manipulate the data within a database.
    12·1 answer
  • Today, air travel allows large numbers of people to move quickly over long distances. Which of the following is a likely effect
    8·1 answer
  • Which type of lenses shrinks the image in front of it rather than magnifying it? A)Telephoto B)Optical zoom C)Digital zoom D)Wid
    10·1 answer
  • Once a graph has been created, you would need to start over to make any changes to it?
    5·1 answer
  • When a Python script is running as a standalone program, what will the __name__ variable be set to?
    7·1 answer
  • Write a program that use a switch statement whose controlling expression is the variable area code. If the value of area_code is
    12·1 answer
  • Which of the following does your textbook recommend for preparing PowerPoint slides? Group of answer choices
    9·1 answer
  • What key should i press to leave the cell as it orginally was
    9·1 answer
  • What is it called when you remove some information from a file or remove a file from the disk ? A) save b) delete c) edit d) rem
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!