AdventureWorks Database: Find the sum of the ListPrice and StandardCost for each color

SQL Query - AdventureWorks: Exercise-100 with Solution

100. From the following table write a query in SQL to calculate the sum of the ListPrice and StandardCost for each color. Return color, sum of ListPrice.

Sample table: production.Product

Click to view Full table

Sample Solution:

SELECT Color, SUM(ListPrice)AS TotalList,   
       SUM(StandardCost) AS TotalCost  
FROM production.product  
GROUP BY Color  

Sample Output:

color       |totallist|totalcost |
Black       |67436.260|38636.5002|
Blue        | 24015.66|14746.1464|
Grey        |      125|   51.5625|
Multi       |   478.92|  272.2542|
Red         | 53274.10|32610.7661|
Silver      | 36563.13|20060.0483|
Silver/Black|   448.13|  198.9700|
White       |    36.98|   13.5172|
Yellow      | 34527.29|21507.6521|
            |  4182.32| 2238.4755|

SQL AdventureWorks Editor:

Practice Online

Contribute your code and comments through Disqus.

Previous: Find the TotalSalesYTD of each SalesQuota.
Next: Calculate salary percentile for each employee for specific department Determine each employee's salary percentile for a particular department.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

Convert Timestamp to date in MySQL Query:

DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'

Database: MySQL

Ref : https://bit.ly/3EJPnMQ