469,902 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Subselect Query taking a long time in SQL Server 7.0

I have a query that I need to run on a database that is on a SQL Server 7 installation. When I run the query on that database it takes forever. If I take the same query and run it on a database that is on a SQL Server 2000 installation it runs under a minute. I was wondering if someone might be able to help me redefine the query so that it works faster under SQL Server 7 but still returns the same results. The query is:

Select DISTINCT A.ID,(Select Top 1 field1 from table1 B
where B.ID=A.ID
order by field1 desc)
as field1
from table1 A
order by ID asc

There are multiple entries for the ID column in the database but what I am looking for is the most recent field1 row only so that is why the subselect. If there is another way to do it, I would be happy to try it. Thanks in advance for the help.
Jun 25 '07 #1
0 1022

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Mike Read | last post: by
6 posts views Thread by Muharram Mansoorizadeh | last post: by
4 posts views Thread by James | last post: by
6 posts views Thread by Sebastien | last post: by
3 posts views Thread by rfuscjr via AccessMonster.com | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.