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
Assuming a computer has a single processor and a single core with no support for parallel execution, explain why running a multi
IRISSAK [1]

Answer:

Explanation:

Before we go deep into this question lets have some brief knowledge on parallel execution, parallel processing and multi tasking.

Parallel Execution : in this two or more tasks or program can be executed parallel or simultaneously.

For example if there are two processors and four programs to be executed then it executes two at a time.

Multi tasking: in this two or more tasks can be performed simultaneously switching between them without exiting any application.

For example we use notepad, word pad, excel sheet, chrome all at a time switching between each other.

Multi Threading: It is splitting up the program into different threads.If the contents in the program are independent on each other then the program can be split into multi threads and can be processed.

Multi threading in multi core or processing unit : In this threads are executed parallel or simultaneously in different processes.

For example if there are two processors then one multi threaded program can execute two threads in two different processors.

Multi threaded program in single core unit : In this, program is multi threaded where as threads cannot execute parallel or simultaneously. they sholud be executed by the same processor. So they should wait in queue

Ex: consider three tasks of 6 secs each and multi threaded each into three threads of two seconds.

Task1 3secs > task2 3secs > task3 3 secs it repeats until each task is completed

Total time taken is 3+3+3+3+3+3+3+3+3 is 18seconds...

If they are executed one by one without multi threading total execution time has no change..

Where as multi threading program has its advantages if different threads are executed at different place..

If one thread executes at network, another at printer and other processor then these three can execute at same time at different processors. Multi threading has its advantages but in single core systems it doesn't affect the performance.

Inter process communication consists of

Information Sharing, message passing, Modularity.

In shared memory inter process communication processes shares the memory between each other.

In message passing communication process communicates like request and replies for information and resources.

Interlocking is due to error in resource sharing and information sharing. It results in system collapse.

Al these process communication is required if there are two or more.processes but in single core it is not much useful and advisable.

In single core there will be a single processor, processing multi threaded program as it can access all the memory contents there will be no problem of process communication. Where as in multi core systems different processes may compete for same memory or resource.

In single core systems inter process communication makes things complex and these complexity is not much useful in any of the improvement in performance.

4 0
4 years ago
What color model should Joe use if he will be using an offset printing press?
EleoNora [17]

Answer:

CMYK

Explanation:

Monitors typically use RGB color (additive model — adding to make white), but offset printing uses CMYK pigments (subtractive color — subtracting from the existing white). Printed images have less visual range, saturation, and contrast than digital images, so in print, colors will usually appear darker and less vibrant.

6 0
3 years ago
One of the disadvantages of Photoshop Express is that it does not have a Black and White effect. True False
Katarina [22]
False,
The Pop Color tool can be used to select one particular color, changing the rest of the image to black and white. The effects available in Photoshop Express don't allow for a huge amount of customization
8 0
3 years ago
When you enforce restrictions, what must you do immediately?
sweet [91]
The answer is A create a password
4 0
3 years ago
Read 2 more answers
you arrive at a scene where a computer must be seized as evidence. the computer is powered off and has an external usb hard driv
larisa [96]

The first thing that must be done is Thoroughly documenting the state of equipment before it is hidden is critical to adhere to chain-of-custody procedures. Failure to do so will render collected evidence inadmissible.

Security+ can be defined as the entry-level cybersecurity credential offered by the CompTIA non-profit trade association. This is usually the first certification in information security that an IT professional obtains. By having this, you may get more job opportunities, because you are judged as a more competitive candidate.

The CompTIA Security+ exam (SY0-601) is a test that tests an applicant that he or she has the basic knowledge to perform tasks in IT security and work in cybersecurity. The CompTIA Security+ exam is a vendor-neutral exam that tests applicants' knowledge of IT security materials and their ability to perform core security functions.

You can learn more about Security+ here brainly.com/question/17109203

#SPJ4

7 0
1 year ago
Other questions:
  • Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targe
    9·1 answer
  • Write a java program which uses methods for calculating the sum of any 5 non-zero integer digits that are input. The program mus
    8·1 answer
  • Convert the binary number into a hexadecimal number.
    7·1 answer
  • It is important to name your files in a variety of formats. true or false
    15·2 answers
  • Linda is viewing the campaign report in her Google Ads account after successfully implementing conversion tracking tags for her
    7·1 answer
  • Riya wants to save her project work in an external device so that she can show it to her class teacher. Help her to choose the d
    13·2 answers
  • How can I make [ print(3 * x) ] into a functional python code?
    8·1 answer
  • If Laura wanted to solve a problem using recursion where the last statement executed is the call to the same method, what type o
    8·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • Please help me on this it’s due now
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!