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 2005 Forums
 Transact-SQL (2005)
 [Solved] Use Top1 or Max()

Author  Topic 

CVDpr
Starting Member

41 Posts

Posted - 2008-10-01 : 10:31:28
Hey There, this two give me the same result/value from a decimal field(xx.x):

select top 1 Version from APCData with(nolock) order by Version desc

select max(version) from APCData with(nolock)

wich of the two is the properway to do it? I want the bigger/max value.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-01 : 10:33:41
I prefer to use second method

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-01 : 10:35:23
I don't think one is better than the other in this case.
Use the approach you feel comfortable with.

To make sure, check out the execution plan.
There could be some difference depending in index strategy.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -