My table in this issue has three columns: Player, Team and Date_Played.
Player Team Date_Played
John Smith New York 2/25/2014
Joe Smith New York 2/25/2014
Steve Johnson New York 2/25/2014
Steph Curry Orlando 2/25/2014
Frank Anthony Orlando 2/26/2014
Brian Smith New York 2/26/2014
Steve Johnson New York 2/27/2014
Steph Curry New York 2/28/2014
I know how to get a list of distinct team names or dates played, but what I'm looking for is a query that will group by Team and count the number of distinct Team & Date combinations. So the output should look like this:
Team Count
New York 4
Orlando 2
So far I have:
SELECT DISTINCT Tm, Count(Date_Played) AS Count
FROM NBAGameLog
GROUP BY NBAGameLog.[Tm];
But this gives me the total amount of records grouped by date.
A bit less code:
SELECT Team, Count(distinct Date_Played) AS Count
FROM NBAGameLog
GROUP BY Team
It does Show the same execution plan as the first answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With