Re: SUM problem.
Something like this, or is it too simplistic ?
mysql>
mysql> select version();
+---------------------+
| version() |
+---------------------+
| 5.0.67-community-nt |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql> use test;
Database changed
mysql>
mysql> drop table if exists top10;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> create table top10 (
-> player smallint,
-> points smallint);
Query OK, 0 rows affected (0.08 sec)
mysql>
mysql> insert into top10 values
-> (1,1),
-> (2,2),
-> (3,3),
-> (4,4),
-> (5,5),
-> (6,6),
-> (7,7),
-> (8,8),
-> (9,9),
-> (10,10);
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql>
mysql> select * from top10 order by points desc limit 8;
+--------+--------+
| player | points |
+--------+--------+
| 10 | 10 |
| 9 | 9 |
| 8 | 8 |
| 7 | 7 |
| 6 | 6 |
| 5 | 5 |
| 4 | 4 |
| 3 | 3 |
+--------+--------+
8 rows in set (0.00 sec)
mysql> select points into @lastpoints from top10 order by points desc limit 7,1;
Query OK, 1 row affected (0.00 sec)
mysql> select @lastpoints;
+-------------+
| @lastpoints |
+-------------+
| 3 |
+-------------+
1 row in set (0.02 sec)
mysql> select sum(points) from top10 where points >= @lastpoints;
+-------------+
| sum(points) |
+-------------+
| 52 |
+-------------+
1 row in set (0.00 sec)
mysql>
mysql> notee
>
Thanks, Jay