I want to get a field value in the row, which has max value of another field in the same table
I have done with the below query. I want to know is there any other better way of doing it becuase it is taking longer time.
Thanks for your help
SELECT Field1
FROM TableName
WHERE Field2 = ( SELECT MAX(field2)
FROM TableName)That shouldn't take too long to process. How many rows, and do you have an index on Field2?|||I have about 200k records. I have index (non-clustered )on field2. More over it is taking about 7 sec to run the above query
Thanks|||...and of those 200K records, how many are typically being returned in the result set? It may take several seconds to display the result set.
Have you tried viewing the query plan?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment