MySQL, Using a Subquery to get Rank of Score -


i trying find out particular player ranks among shooting guards in nba. using this post on stackoverflow guide.

i error "invalid use of group function".

  select   first,   last,   team,   pos,   sum(points) scoresum,   round(avg(points), 2) avgpoints,   (select      count(*)    nbaboxscore bpnb    (bpnb.first, bpnb.last, sum(bpnb.points)) >= (bpn.first, bpn.last, sum(bpn.points))) rank nbaboxscore bpn bpn.pos = 'sg'     , bpn.date >= '2009-10-01'     , first = 'joe'     , last = 'johnson' group bpn.first, bpn.last, bpn.team order scoresum desc 

i'm not sure if it's possible way?

your subquery wrong, cannot use sum without group by , in where, have use having. let check : http://dev.mysql.com/doc/refman/5.0/fr/select.html


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -