Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Alternative to Top 1

Author  Topic 

pattikay
Starting Member

36 Posts

Posted - 2001-11-09 : 09:57:19
I have noticed that the logical reads of queries reduce greatly when you use
'select min(column_name)from table'
instead of 'select top 1 column name from table'.
This works well until I encounter a select statement that has an order by clause. Does anyone have any ideas of using select min(column_name) from table when there is an order by clause or of a way of using it without the order by clause but still getting the desired effect?

Here is an example of a query that I am trying to modify:

select loc_name from cfg_locations
where loc_id = (select top 1 current_locations.cul_locationid from current_locations where
cul_atdid = atd_id order by cul_culid desc )
Thanks alot in advance.

   

- Advertisement -