How to directly get the record number from the query results?