KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy SQL for KDB Challenge School admission Project Exercise 6 test issue

  • SQL for KDB Challenge School admission Project Exercise 6 test issue

    Posted by Angus on August 14, 2024 at 8:50 am

    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 87

    house avg_mark
    ——————-
    Gryffindor 75
    Ravenclaw 88
    Slytherin 88

    The 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?

    replied 9 months ago 0 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.