Skip to content
Advertisement

Finding average highest salary

Write a query to find the highest average sales among all the salespersons using the given table.

Sample

Sample output

I tried using: SELECT MAX(TotalSale) FROM Sales. My output for sample test case was 250 but it was given wrong answer verdict in an online judge. Also, when I changed the query to : SELECT MAX(TotalSale*1.0000) FROM Sales,I got correct answer for sample test case but still wrong answer for other test cases.

What is meant by average here? What should be the query?

Also, this isn’t from any on-going competition. It is from a practice test which you can attempt here: https://www.hackerearth.com/challenge/test/kredx-data-analyst-test/

Advertisement

Answer

1.First you have to calculate the average TotalSale for each SalesPerson using the AVG function.

2.Find out the max value from the table generated by the above query.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement