Retired

SQL Basics: Simple HAVING (OLD) (retired)

Description
Loading description...
Fundamentals
SQL
Databases
Information Systems
Data
  • Please sign in or sign up to leave a comment.
  • archrisV Avatar

    You should make this kata solvable or outright remove it, because it's suck in my unsolved katas, and it's pissing me off.

  • nhpatt Avatar

    It can't be solved right now :'(

  • Late347 Avatar

    I tried to use

    GROUP BY people.id desc

    but it gave an error, I don't understandt what is wrong about that. EDIT: OK it was supposed to be order by desc

    What is the difference in SQL between HAVING COUNT and HAVING?

    • matt c Avatar

      I beleive there is no issue here so resolving. also I don't exactly understand your question?

      Issue marked resolved by matt c 9 years ago
  • pmatseykanets Avatar

    I agree with @cubittz that this is suboptimal and misleading example of using HAVING clause for someone who's learning SQL.

    • matt c Avatar

      do you have a suggestion

    • pmatseykanets Avatar

      Sure.

      With a data set close to yours an assignment can potentially read "Find all ages that more than one person has". Here is SQLFiddle This is a very typical use case. Another example: "Given a posts table with columns (id, title, author_id) find all author_id's that published more than two blog posts". SQLFiddle. You can sprinkle both examples with ORDER BY by requiring to sort the result set one way or another.

      Please let me know if I can help more.

    • matt c Avatar

      good to see someones being mature with downvotes..

      I've been trying to update a fix for awhile now and I did have one awhile ago but the recurring issues with republishing katas has stopped it from updating.

      bear in mind this will be invalidating 160 solutions.

    • pmatseykanets Avatar

      Maybe introduce an improved kata, put a disclaimer in this one and eventually discontinue it?

    • matt c Avatar

      I don't believe it's possible to discontinue an already approved kata..

    • matt c Avatar

      I've published a new one.

  • cubittz Avatar

    For people learnng SQL I think this Kata is a misleading example of HAVING. Sure, it gets the result, but grouping by id, which is a unique field?! 100% of developers would approach this problem using a where clause.

  • JohanWiltink Avatar

    Also, the tests for the WHERE clause say they are testing for the presence of WHERE instead of the absence. Both Example and Submit Tests.

  • JohanWiltink Avatar

    This could have been done with a WHERE clause. When working with aggregated values, there are things which cannot be done with a WHERE clause and have to be done with a HAVING clause. Wouldn't it be more clear to do with a WHERE clause what can be done with a WHERE clause and do with a HAVING clause what has to be done with a HAVING clause?

    (I have always lived under the presumption SQL actually required this anyway. Apparently, I was wrong, at least for this implementation of SQL.)

  • user5036852 Avatar

    The test with the message "should contain WHERE" misses the "no" or "not" in example and real tests!