Section G (7 points) Suppose we have the following Product table: ProductID ProductName Company TotalSalesAmount_in_K 1 Digital pen Dell 50 2 Mouse Dell 45 3 USB IBM 25 4 Digital pen IBM 70 5 Mouse IBM 40 6 USB Dell 80 7 Battery Dell 135 8 Battery IBM 120 # Question Answer 1 Write a SQL query that process the following query: "Rank the products in the descending order of TotalSalesAmount_in_K for each company. Display Company, ProductName, Rank, and TotalSalesAmount_in_K" (7 points)
Added by Tom R.
Close
Step 1
Step 1: The query starts by selecting the columns Company, ProductName, RANK() OVER (PARTITION BY Company ORDER BY TotalSalesAmount_in_K DESC) AS Rank, and TotalSalesAmount_in_K from the table Product. Show more…
Show all steps
Your feedback will help us improve your experience
Brooke Bussoletti and 98 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Arrange the above set of data in ascending order 10,20,20,30,30,40,60
Brooke B.
Select the acid with the highest $\mathrm{K}_{\mathrm{a}}$ (i.e., lowest $\mathrm{pK}$ )?
Write a query to retrieve the most valuable customer of each year. The most valuable customer of a year is the customer who has made the most purchases for the year. Use the yearly sum of the TotalDue column in SalesOrderHeader as a customer's total purchase for a year. If there is a tie for the most valuable customer, your solution should retrieve it. Include the customer's id, total purchase, and total order count for the year. Display the total purchase as an integer using CAST. Sort the returned data by the year.
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD