6 kyu

SQL Bug Fixing: Fix the JOIN

9,356matt c

Description:

Oh no! Timmys been moved into the database divison of his software company but as we know Timmy loves making mistakes. Help Timmy keep his job by fixing his query...

Timmy works for a statistical analysis company and has been given a task of calculating the highest average salary for a given job, the sample is compiled of 100 applicants each with a job and a salary. Timmy must display each unique job, the total average salary, the total people and the total salary and order by highest average salary. Timmy has some bugs in his query, help Timmy fix his query so he can keep his job!

people table schema

  • id
  • name

job table schema

  • id
  • people_id
  • job_title
  • salary

resultant table schema

  • job_title (unique)
  • average_salary (float, 2 dp)
  • total_people (int)
  • total_salary (float, 2 dp)

NOTE: Your solution should use pure SQL. Ruby is used within the test cases to do the actual testing.

SQL
Fundamentals

Stats:

CreatedOct 25, 2016
PublishedOct 25, 2016
Warriors Trained23295
Total Skips3308
Total Code Submissions101083
Total Times Completed9356
SQL Completions9356
Total Stars233
% of votes with a positive feedback rating78% of 1219
Total "Very Satisfied" Votes785
Total "Somewhat Satisfied" Votes336
Total "Not Satisfied" Votes98
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • matt c Avatar
  • jhoffner Avatar
  • Unnamed Avatar
  • user5036852 Avatar
Ad