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.
Yeah, I had the same question. I think I understand now. We thought it would be OK to group by id only because we KNEW that id and name are uniquely paired to each other. However sql does not know that and cannot assume that. If we group by id only, then from sql's point of view, it may well be possible that multiple different names corresponding to the same id are counted together. Therefore sql cannot print a separate column for name.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Top Competitors
You are viewing a single comment's thread. Return to all comments →
Yeah, I had the same question. I think I understand now. We thought it would be OK to group by id only because we KNEW that id and name are uniquely paired to each other. However sql does not know that and cannot assume that. If we group by id only, then from sql's point of view, it may well be possible that multiple different names corresponding to the same id are counted together. Therefore sql cannot print a separate column for name.