tags:

views:

37

answers:

2

i am trying to teach myself SQL and of course I would like to follow best practices.

I have created two querys to find the latest record :

select * from AppSurvey where 
DateLastUsed >= ( SELECT MAX(DateLastUsed) FROM AppSurvey)

and

select top 1 * from AppSurvey order by DateLastUsed desc

is one of these methods more efficent than the other or does it really matter

+1  A: 

The first one could get more than one row, if your DateLastUsed column isn't unique.

Matt Hamilton
+1  A: 

There is a similiar post on this site to what you are trying to get at.

http://stackoverflow.com/questions/590079/for-autoincrement-fields-maxid-vs-top-1-id-order-by-id-desc

The preferred answer seems to be: "In theory, they will use same plans and run almost same time"

Jride