Wednesday, March 7, 2012

Quick method to determine relative position of the index entry

I have a large table with some indexes.
And I have a value for an indexed field. So I'd like to get the order of the first entry of this value in a specified index.

I'd like to write a stored procedure, which returns such number for given value and index name.

How can I do it?I have found a quik decision!

select count(distinct indexed_col_name)
from Table
where index_col_name < value

Other ideas (with Cursor , for example) are slower.

No comments:

Post a Comment