﻿ AdventureWorks: Return the highest hourly wage for each job title

# AdventureWorks Database: Return the highest hourly wage for each job title

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

125 From the following tables write a query in SQL to return the highest hourly wage for each job title. Restricts the titles to those that are held by men with a maximum pay rate greater than 40 dollars or women with a maximum pay rate greater than 42 dollars.

Sample table: HumanResources.Employee

Click to view Full table

Sample table: HumanResources.EmployeePayHistory

Click to view Full table

Sample Solution:

``````SELECT JobTitle, MAX(ph1.Rate)AS MaximumRate
FROM HumanResources.Employee AS e
GROUP BY JobTitle
HAVING (MAX(CASE WHEN Gender = 'M'
THEN ph1.Rate
ELSE NULL END) > 40.00
OR MAX(CASE WHEN Gender  = 'F'
THEN ph1.Rate
ELSE NULL END) > 42.00)
ORDER BY MaximumRate DESC;
``````

Sample Output:

```jobtitle                        |maximumrate|
--------------------------------+-----------+
Chief Executive Officer         |      125.5|
Vice President of Production    |    84.1346|
Vice President of Sales         |    72.1154|
Vice President of Engineering   |    63.4615|
Chief Financial Officer         |    60.0962|
Research and Development Manager|    50.4808|
Information Services Manager    |    50.4808|
North American Sales Manager    |     48.101|
Pacific Sales Manager           |     48.101|
European Sales Manager          |     48.101|
Engineering Manager             |    43.2692|
Finance Manager                 |    43.2692|
```

## 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'`