educative.io

Is it just me, or 2nd question just doesn't make sense, is there an error?

I have two question for the 2nd question in the Quiz:

  1. The logic in this query doesn’t make sense for me. We are grouping by email… but we put email in the aggregate function SUM and leave users without it, which is really strange, for what I know - it would cause the query to crash because we have to group by the same field which is left without any aggregate function in the SELECT? It’s not supposed to work this way, and the answer would be actually correct if we grouped by users instead. Right?
  2. And what up with the strange tabulation of the query? Is it intended?

Thanks!


Course: https://www.educative.io/collection/5352985413550080/6335716377231360
Lesson: https://www.educative.io/collection/page/5352985413550080/6335716377231360/5707471738896384

Hey, @Dmitry_Polovinkin!

I hope you’re doing well. The query in the question selects name and count(email), and the query is specifically to find the duplicate entries. As per your suggestion, if we write name in the GROUP BY clause, the query will print each name with an email count, which would obviously be 1 in each entry. However, the correct query would be:

  SELECT email, COUNT(email)
    FROM users
GROUP BY email
  HAVING COUNT(email)>1;

This query will find all duplicate records based on email address. We have updated the query and also fixed the indentation of the query. We hope Educative has inspired you to further your learning.

thanks! the work of the author of those lessons should really be reviewed because of so much errors there in this course

Hey, @Dmitry_Polovinkin!

I hope you’re doing great. Thank you for contacting us with your concerns. Our dedicated team is actively addressing the issue at hand. We have conducted a comprehensive review of the course and have already initiated communication with the course author regarding the identified issues. We are committed to resolving this matter promptly, and we anticipate a resolution in the near future.

We appreciate your patience and understanding as we work towards a solution. Please feel free to reach out if you have any further questions.