March 23, 2016 at 11:26 pm
Comments posted to this topic are about the item More GROUP BY
March 23, 2016 at 11:27 pm
This was removed by the editor as SPAM
March 24, 2016 at 1:22 am
Easy.. Thanks
March 24, 2016 at 4:43 am
Nice question, but awarding points for and titling "Group by" is a big hint, so alternatives without group should be automatically excluded.
Anyway nice question and nice count distinct trick.
March 24, 2016 at 5:24 am
l.vignando (3/24/2016)
Nice question, but awarding points for and titling "Group by" is a big hint, so alternatives without group should be automatically excluded.Anyway nice question and nice count distinct trick.
Nice question. However, I've seen using the title as a hint produce the wrong result before. Yes, it was a hint here, but not always. 😉
March 24, 2016 at 5:44 am
The explanation excludes the DISTINCT keyword, which might be confusing if you didn't already know the correct answer.
March 24, 2016 at 7:01 am
Interesting question. The wrong answers were obvious. But the right answer I had to think about. I've never constructed a query like that before, using distinct in the HAVING clause's COUNT. I've used it in a simple select COUNT(distinct..., just not with the HAVING part.
March 24, 2016 at 8:12 am
Really, really easy. Thanks, Steve!
March 24, 2016 at 8:42 am
I think with the current data model and lack of constraints you would actually want both.
WHERE Played = 'Rock' OR Played = 'Paper' OR Played = 'Scissors'
GROUP BY Person HAVING COUNT(DISTINCT Played) = 3
but the group by is key to the solution.
March 24, 2016 at 9:02 am
Shouldn't it be COUNT(DISTINCT Played) >= 3, in case some decides to play 'switch kick to the nuts'? 😛
March 24, 2016 at 11:05 am
Nice question, Steve. However, it won't work if the players are playing Rock, Paper, Scissors, Lizard, Spock. 🙂
March 24, 2016 at 11:16 am
Joel Ewald (3/24/2016)
I think with the current data model and lack of constraints you would actually want both.WHERE Played = 'Rock' OR Played = 'Paper' OR Played = 'Scissors'
GROUP BY Person HAVING COUNT(DISTINCT Played) = 3
but the group by is key to the solution.
Good catch!
March 24, 2016 at 11:43 am
stephen.long.1 (3/24/2016)
Nice question, Steve. However, it won't work if the players are playing Rock, Paper, Scissors, Lizard, Spock. 🙂
I deliberately left that out for another day.
March 24, 2016 at 3:30 pm
Good easy way to end the week (wishing it was Friday), but the query would error in all cases:
the table is created as [RPSGame], but the FROM clause references [RPSGames]. Too bad/so sad.
So ha! I caught the trick!
Mark
Just a cog in the wheel.
March 24, 2016 at 5:14 pm
starunit (3/24/2016)
Good easy way to end the week (wishing it was Friday), but the query would error in all cases:the table is created as [RPSGame], but the FROM clause references [RPSGames]. Too bad/so sad.
So ha! I caught the trick!
Thanks. Corrected.
Viewing 15 posts - 1 through 15 (of 21 total)
You must be logged in to reply to this topic. Login to reply