Reply to Re: Which has the best performance?

Your name:

Reply:


Posted by Greg D. Moore \(Strider\) on 06/06/05 19:04

"Robin Tucker" <idontwanttobespammedanymore@reallyidont.com> wrote in
message news:d81e60$hpa$1$830fa7a5@news.demon.co.uk...
>
> This:
>
> SELECT MAX(TheDate) FROM MyTable
>
> or this:
>
> SELECT TOP 1 TheDate FROM MyTable ORDER BY TheDate DESC
>
>
> As a follow up question to save me having to post, if I want a different
> field from the result set of a MAX query, how do I do it? ie. I want the
> "Condition" field of the record with the most recent date. I have been
> doing it like this:
>
> SELECT TOP 1 Condition FROM MyTable ORDER BY TheDate DESC
>
> but if MAX(TheDate) is quicker, I would like to SELECT TOP 1 Condition
.....
> where TheDate is the max date...... Hope this makes sense.....

Probably Select MAX, but really the only way to tell is to try it on your
schema and look at the plans, etc.

In addition,as TOP 1 is T-SQL specific, I'd be much more likely to go with
the MAX option.


>
> Basically, I'm going to be performing this query nested inside another
query
> and I want the maximum performance possible (indexes are a different
> question), which means trying to avoid table scans....
>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация