Monthly Archives: March 2008

>T-SQL: Top N Rows Per Group

> The following will return the top 10 players who hit the most home runs per year since 1990. The key is to calculate the “Home Run Rank” of each player for each year. selectHRRanks.*from(Selectb.yearID, b.PlayerID, sum(b.Hr) asTotalHR,rank() over (partition … Continue reading

Posted in database | Leave a comment