-
SQL for KDB Challenge School admission Project Exercise 6 test issue
Exercise 6 requests the average score of a joined table to be rounded down.
“Show the average marks per house using SQL Join, call the new column avg_mark. This new value should be rounded down (i.e. contain no decimal values).”
The test fails when using the following code:
select house, floor(AVG(mark)) as avg_mark
From results LEFT JOIN students on results.student_no = students.student_no
group by house
test:
quizItem success description error
————————————————————————–
exercise6 Pass “ex6 defined and contains correct sql syntax” “”
exercise6 Pass “result from .s.e ex6 has correct table structure” “”
exercise6 Fail “result from .s.e ex6 has correct records” “”The correct answer for this test is:
select house, round(AVG(mark)) as avg_mark
From results LEFT JOIN students on results.student_no = students.student_no
group by house
The two statements return the following respectively:
house avg_mark
——————-
Gryffindor 75
Ravenclaw 88
Slytherin 87house avg_mark
——————-
Gryffindor 75
Ravenclaw 88
Slytherin 88The contested mark from Slytherin is 87.5 before rounding, if the task is to round down the avg_mark, why does the test fail with a mark 87 but pass with 88?
Sorry, there were no replies found.
Log in to reply.