strano, a me funziona bene, ho riprodotto il tutto per curiosita':
come si puo' vedere, sia la mia query che quella di nicola danno lo stesso risultato.codice:$ /usr/local/mysql5/bin/mysql -p Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.1.36 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use test; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> create table tabella (id int, punteggio int) engine myisam; Query OK, 0 rows affected (0.00 sec) mysql> insert into tabella values (1,50),(2,20),(3,40),(4,100),(5,76),(6,11); Query OK, 6 rows affected (0.00 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> select count(distinct punteggio)+1 as posizione from tabella where punteggio > (select punteggio from tabella where id = 3); +-----------+ | posizione | +-----------+ | 4 | +-----------+ 1 row in set (0.00 sec) mysql> select count(*) + 1 as posizione from (select * from tabella where punteggio > (select punteggio from tabella where id=3) order by punteggio desc) as tab; +-----------+ | posizione | +-----------+ | 4 | +-----------+ 1 row in set (0.00 sec)
che versione di mysql avete?

Rispondi quotando