Right answer not working?

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

I’m facing a really hard time trying to understand why my answer is not being accepted by the exercise.

My code:

WITH playlist_info AS
	(SELECT
		p.playlist_id,
		p.name AS playlist_name,
		t.name AS track_name,
		(t.milliseconds/1000) AS lenght_seconds
	FROM playlist AS p
	LEFT JOIN playlist_track AS pt ON pt.playlist_id = p.playlist_id
	LEFT JOIN track AS t ON t.track_id = pt.track_id)
SELECT 
	playlist_id, playlist_name, 
	COUNT(track_name) AS number_of_tracks,
	SUM(lenght_seconds) AS lenght_seconds
FROM playlist_info
GROUP BY 1, 2
ORDER BY 1;

Code from the answer:

WITH playlist_info AS
    (
     SELECT
         p.playlist_id,
         p.name playlist_name,
         t.name track_name,
         (t.milliseconds / 1000) length_seconds
     FROM playlist p
     LEFT JOIN playlist_track pt ON pt.playlist_id = p.playlist_id
     LEFT JOIN track t ON t.track_id = pt.track_id
    )

SELECT
    playlist_id,
    playlist_name,
    COUNT(track_name) number_of_tracks,
    SUM(length_seconds) length_seconds
FROM playlist_info
GROUP BY 1, 2
ORDER BY 1;

The only difference I can detect is that I’m usin “AS” to create the aliases. Is there anything else that I’m missing???

1 Like

Hi @phssaraiva:

Looks like a minor typo. You spelt length incorrectly at 3 places.

2 Likes

Indeed @masterryan.prof :100:
That’s the reason why you are seeing the error. Otherwise everything is fine in your code @phssaraiva

2 Likes

Thank you guys… I really didn’t notice that.

Ya @phssaraiva at time I can’t spot my error and have to ask a friend to go through it for me too haha…

1 Like