w3resource

AdventureWorks Database: Populate the variance of all unique values and all values

SQL Query - AdventureWorks: Exercise-97 with Solution

97. From the following table write a query in SQL to populate the variance of all unique values as well as all values, including any duplicates values of SalesQuota column.

Sample table: sales.salespersonquotahistory


Click to view Full table

Sample Solution:

SELECT var_pop(DISTINCT SalesQuota) AS Distinct_Values, var_pop(SalesQuota) AS All_Values  
FROM sales.salespersonquotahistory;

Sample Output:

distinct_values      |all_values           |
---------------------+---------------------+
158146830494.18114353|157788848582.93499944|

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Compute the variance of sales quota for each quarter in a year.
Next: Find total ListPrice and StandardCost of products of distinct color.

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