We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Instead of using count(id) > 2 like that, I'd recommend using Distinct. It does what you're looking for more simply, and would eilminate any possible logic errors from your query.
Try something like Select((Count(City) - Count(Distinct city)) From Station
That way you can avoid group bys and havings that have a habit of behaving in ways you don't expect, and it makes your query more readable, and I suspect faster.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 4
You are viewing a single comment's thread. Return to all comments →
Instead of using count(id) > 2 like that, I'd recommend using Distinct. It does what you're looking for more simply, and would eilminate any possible logic errors from your query.
Try something like Select((Count(City) - Count(Distinct city)) From Station
That way you can avoid group bys and havings that have a habit of behaving in ways you don't expect, and it makes your query more readable, and I suspect faster.