Reputation: 67
This line of code is simple and I understand what the query will return. I am trying to understand the third line of this code.
select First
, sum(rbi) as 'rbis'
**, count(*) as 'num_players'**
from #batter_stats
group by First
having count(*) >= 5
order by [rbis] desc
The count(*) as 'num_players'
is confusing me as to what this does in this query.
Thanks you. I provided both the line of code and the data table.
Upvotes: 2
Views: 136
Reputation: 133380
In your code the aggregation functions
, sum(rbi) as rbis
, count(*) as num_players
agregated by column First
count(*)
retunr the number of rows for the corresponding groped value
so in your case retunr the number of rows in your table for the corresponding value of olumn First
Upvotes: 1