in reply to Ranking position in a SQL index
SELECT COUNT(*) FROM table WHERE numeric_column < (SELECT numeric_column FROM table WHERE your_criteria)
In my version of mysql, subqueries aren't supported, so I actually have to save the subselect results into a variable, then do the second select, but EXPLAIN says this similar query is reasonably well-optimized:
mysql> explain select count(*) FROM faar_homes WHERE price < 80000 \G *************************** 1. row *************************** table: faar_homes type: range possible_keys: price key: price key_len: 5 ref: NULL rows: 25 Extra: where used; Using index
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Ranking position in a SQL index
by pg (Canon) on Oct 05, 2004 at 04:53 UTC |