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
Write a program that asks the user how many numbers will be entered and then has the user enter those numbers. When this is done
KATRIN_1 [288]

Answer:

<em>The program written in Python 3 is as follows;</em>

<em>The program does not make use of comments; however, see explanation section for detailed line by line explanation of the program</em>

num = int(input("Number of Inputs: "))

mylist = []

userinput = int(input("Enter a digit: "))

i = 1

while i < num:

     mylist.append(userinput)

     userinput = int(input("Enter a digit: "))

     i += 1

   

try:

     first7 = mylist.index(7)+1

     print('The first position of 7 is ',first7)

     last7 = num - 1 - mylist[::-1].index(7)

     print('The last position of 7 is ',last7)

except:

     print('7 is not on the list')

Explanation:

This line prompts user for the number of inputs

num = int(input("Number of Inputs: "))

This line declares an empty list

mylist = []

This line inputs the first number into the empty list

userinput = int(input("Enter a digit: "))

The italicized lines represent an iteration that allows user to input the numbers into the empty list.

<em>i = 1</em>

<em>while i < num:</em>

<em>      mylist.append(userinput)</em>

<em>      userinput = int(input("Enter a digit: "))</em>

<em>      i += 1</em>

The try-except is used to check the presence of 7 in the list

try:

This checks the first occurrence of 7

     first7 = mylist.index(7)+1

This prints the first occurrence of 7

     print('The first position of 7 is ',first7)

This checks the last occurrence of 7

     last7 = num - 1 - mylist[::-1].index(7)

This prints the last occurrence of 7

     print('The last position of 7 is ',last7)

The following is executed if there's no occurrence of 7

except:

     print('7 is not on the list')

See Attachments for sample runs

7 0
3 years ago
The picture that graphically represents the items you use in Windows is called a/an
Novosadov [1.4K]
The answer to this is Bulls icon
6 0
4 years ago
What is most likely to happen to the purchasing power of money over time?
natima [27]

Answer:

A

Explanation:

6 0
3 years ago
Signs that a listener is paying attention include:
Tomtit [17]
Eye contact, Taking notes, being quiet.I mean there is a lot of ways
6 0
3 years ago
Read 2 more answers
You are the leader of your school's Go Green Club, which supports environmentally friendly choices and lifestyles. Your club wil
miskamm [114]

Answer:

(Answers may vary.)

My Considerations

The Go Green Club has a total of 100 members. I plan to photograph each of them in front of our club's "Go Green" sign. I have a deadline of 30 days to deliver the ID cards. Therefore, I have to ensure that all the cards are printed and ready for delivery in 20 days, with 10 days of buffer time (in case the cards require any edits or changes). Additionally, after I have submitted the draft for review, I will need the coordinator's final approval on the design and layout of the ID card.

Hardware Requirements

  • a desktop computer or laptop with adequate memory to run the software to create the ID cards
  • some external storage devices, such as pen drives and DVD disks, to share the design and layout for the coordinator to review; I will also need these devices to store the final digital file for print
  • a color scanner to scan hand-drawn artwork and signatures, which I will place on the ID card
  • a digital camera to capture photos of members, and to transfer them to the computer/laptop
  • a printer to make hard copies of the cards.
  • Software Requirements

I intend to use Scribus to create the ID cards because it is a free DTP application, and has most of the common features I'd need to create an ID card.

Formatting Techniques

  • I plan to use the following techniques to design the club ID cards.
  • I'll use the landscape or horizontal orientation. This will enable proper spacing for the ID card elements.
  • I'm planning to use a card measuring 3.370 inches × 2.125 inches. A card this size will ensure that all the elements of the card are visible.
  • I am planning to place the club logo on the top left corner, because the eye normally follows the path of the letter Z. This'll help the viewer to see the logo and identify/recognize the club.
  • Next I'll place the club name; I'll use the top-center alignment and also vertically align it to the logo. I'll use the sans serif font for the club name.
  • Following the Z-path rule, I'll place the member's photo to the right and the member's name under the photo. In this position, the photo and the name will be visible, and will not get mixed up with other elements. I'll print the member name with a serif font.
  • Finally, again in line with the Z-path rule, I'll position the club seal and the club director's signature at the right lower bottom. Although these elements are essential on an ID card, they do not require as much viewer attention as the club logo, name, and member photo.

Explanation:

I used Canva for this card.

8 0
3 years ago
Other questions:
  • What types of data are commonly entered into a cell ?
    7·2 answers
  • PLS HELP ASAP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    15·1 answer
  • Write two statements to read in values for birthMonth followed by birthYear, separated by a space. Write a statement to print th
    12·1 answer
  • Disconnecting or making the equipment safe involves the removal of all energy sources and is known as _____________. A) Isolatio
    8·2 answers
  • The major difference between a calculator and a computer, when performing calculations, is that a
    10·1 answer
  • 5. How is shutter speed generally measured? What do the measurements mean?
    7·2 answers
  • Travis sends Suri what purports to be a link to an e-birthday card, but when she clicks on the link, software is downloaded to h
    11·1 answer
  • Nonverbal messages from the movie it​
    5·2 answers
  • Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The fi
    5·1 answer
  • Hey, Another question. I'm sure it's possible in the future, but I wanted to ask if HIE would be possible. I'm sure it would be,
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!