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
rodikova [14]
2 years ago
9

A department store maintains data on customers, products, and purchase records in three tables: customer, product, and purchase.

the store manager wants to know which product is on maximum discount for each category. write a query to print the following fields for each category, ordered by category, ascending: category, product id and discount for the product that has the maximum discount in the category. in the case of multiple products having same maximum discount within a category, print the product with minimum product_id.
Computers and Technology
1 answer:
saw5 [17]2 years ago
8 0
<h3>The maximum discount using SQL</h3>

Product_Id  Product_Name   Category  Price   Discount  Available

    1           P-1            C-5        720     10       1

    2           P-2            C-1        935     17       1

    3           P-3            C-2        588     19       1

    4           P-4            C-4        619     5        0

    5           P-5            C-1        803     16       1

<h3>The Output </h3>

C-1 2 17

C-2 3 19

C-4 4 5

C-5 1 10

The code that would print the fields in SQL for the maximum discount is:

WITH newTable AS (

SELECT

t.Category,

t.Product_Id,

b.Discount as maxDiscount,  

ROW_NUMBER() OVER (

                        PARTITION BY t.Category

                        ORDER BY Product_Id DESC

                  ) AS [ROW NUMBER]

FROM Products t

INNER JOIN

(

 SELECT MAX(Discount) as maxDiscount, Category

 FROM Products

GROUP BY Category

) b ON t.Discount = b.Discount AND t.Category = b.Category)

select Category,Product_Id,maxDiscount from newTable

WHERE newTable.[ROW NUMBER] = 1

Read more about SQL here:

brainly.com/question/25694408

#SPJ1

You might be interested in
Could anyone help me with this assignment please?
kicyunya [14]

Answer:

"Word Processing Assignment

5 0
3 years ago
Intellectual property rights are exclusive rights that help protect both the created and the creation. IPR offers exclusively wh
dedylja [7]
IPR offers ownership of the intellectual property. The owner of the property has the right to a monetary gain from those who wish to use it.
8 0
3 years ago
Read 2 more answers
Source Code for TF2 - Please insert it here
Advocard [28]

Answer:

Hi T!

Explanation:

How are you?

3 0
3 years ago
While troubleshooting a connectivity issue in your network, you did a Ping from Host A to Host B, and the Ping was successful. F
xeze [42]

Answer:

Above OSI Layer 3

Explanation:

5 0
3 years ago
Drag the tiles to the correct boxes to complete the pairs.
LiRa [457]

The matchup are:

  • information support and services - providing technical assistance to users
  • network systems - creating interactive materials
  • programming and software development - designing and developing applications for an organization's use
  • web and digital communications -developing and implementing an
  • organization's technology infrastructure

<h3>What is network system?</h3>

A network is known to be made up of a set of computers, servers, network devices, and other devices that are linked so that it can allow data sharing.

Therefore, The matchup are:

  • information support and services - providing technical assistance to users
  • network systems - creating interactive materials
  • programming and software development - designing and developing applications for an organization's use
  • web and digital communications -developing and implementing an
  • organization's technology infrastructure

Learn more about network systems from

brainly.com/question/1326000

#SPJ1

6 0
2 years ago
Other questions:
  • Anne-Marie Cole runs the sales division for a local auto insurance firm. One of her key duties is to calculate her company's mar
    13·1 answer
  • Describe any four rights of users of information systems.
    8·1 answer
  • Which of the following is the MOST likely cause of the connectivity issues?A user of the wireless network is unable to gain acce
    5·1 answer
  • The assignment of numeric codes to characters follows a specific order called a(n) _____.
    15·1 answer
  • Recall that TCP can be enhanced with SSL to provide process-to-process security services, including encryption. Does SSL operate
    7·1 answer
  • On the server side, the database environment must be properly configured to respond to clients' requests in the fastest way poss
    12·1 answer
  • Which of the following are true if you pay only the minimun amount each month towards your credit card bill? You will be charged
    11·1 answer
  • Mika forgot to put in the function name in his function header for the code below. What would be the best function header?
    12·2 answers
  • Python 3.12 LAB: Input and formatted output: Right-facing arrow Given input characters for an arrowhead and arrow body, print a
    15·1 answer
  • Which three options below describe typographic hierarchy?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!