﻿ AdventureWorks: Find different sales quotas for a employee over next years

# AdventureWorks Database: Find different sales quotas for a employee over next years

## SQL Query - AdventureWorks: Exercise-109 with Solution

109. From the following table write a query in SQL to return the difference in sales quotas for a specific employee over subsequent years. Return BusinessEntityID, year, SalesQuota, and the salesquota coming in next row.

Sample table: Sales.SalesPersonQuotaHistory

Click to view Full table

Sample Solution:

``````SELECT BusinessEntityID, date_part('year',QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota,
FROM Sales.SalesPersonQuotaHistory
``````

Sample Output:

```businessentityid|salesyear|currentquota|nextquota|
----------------+---------+------------+---------+
277|   2011.0|      565000|   872000|
277|   2011.0|      872000|   846000|
277|   2011.0|      846000|   952000|
277|   2012.0|      952000|  1600000|
277|   2012.0|     1600000|  1352000|
277|   2012.0|     1352000|   839000|
277|   2012.0|      839000|        0|
```

## Practice Online

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

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