The error🙁 :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY RealmID' at line 1
My code:
$result=mysql_query("SELECT Rname, SUM(NW) as rank FROM users ORDER BY rank DESC GROUP BY RealmID",$link ) or die(mysql_error());
Rname is my column that contains the realm names.
NW is the amount of NW in each realm
RealmID is the realm number ("realm" in the example)
Maybe its my above example confusing everyone, let me simplify my problem:
My table currently has;
id | Realm| NW |
1 | 00001 | 1000
2 | 00002 | 1010
3 | 00001 | 900
I want to display the following after adding up the total NW in each distinct Realm, it displays from total largest to Smallest NW. like;
rk| Realm| NW |
1 | 00001 | 1900
2 | 00002 | 1010
Where rk is rank.
Think this is the most complicated query statement that i've encountered so far...Any help / comments is greatly appreciated. Thanks.