Why are results rounded to nearest second / is this a bug?

Screen Link: https://app.dataquest.io/m/190/building-and-organizing-complex-queries/3/the-with-clause

My Code:

WITH playlist_info AS (
        playlist.playlist_id AS playlist_id,
        playlist.name AS playlist_name,
        track.name AS track_name,
        track.milliseconds / 1000.0 AS track_length_s
    FROM playlist
    LEFT JOIN playlist_track ON playlist.playlist_id = playlist_track.playlist_id
    LEFT JOIN track ON track.track_id = playlist_track.track_id

    COUNT(track_name) AS number_of_tracks,
    SUM(track_length_s) AS length_seconds
FROM playlist_info
GROUP BY playlist_name, playlist_id
ORDER BY playlist_id;

What I expected to happen:

  • pass test and move onto next screen

What actually happened:

  • “The value for result doesn’t look right.”

This seems to be because my “length_seconds” column isn’t rounded to the nearest second (since I made sure to use a float when converting from milliseconds to seconds), whereas the ‘correct’ answer uses integer division and therefore returns answers rounded to the nearest second. But I don’t see anywhere in the question where it asks us to round our results. Did I miss this instruction, or did whoever wrote this answer forget about floats vs integers?

1 Like

Hi @supermartha:

I think you are right. The instructions are a little vague.

If I were to do this mission step (which I have not), I probably would not think of the issue of precision (that is, retaining the float value after division) :sweat_smile:.

The length of each track in seconds.
Probably should have been The length of each track in seconds to the nearest second.

Do you mind filling in this ticket so that the content creation team could rectify this? Thanks for your help!

Tagging @Sahil about the feedback!


Thanks! I’ve submitted a ticket.

Responded via ticket #51151