lets say a column using int as datatype
for eg:
the current method i used to retrieve the largest value is by...
select TOP 1 ...from....order by desc
so for eg:
let say the column contains
10
60
40
25
40
i will only retrieve 60. are there any loophole in the above method?Why not try this:
SELECT MAX(<field>) as MaxValue <from <TABLE> where <CLAUSE>|||Originally posted by Bascy
Why not try this:
SELECT MAX(<field>) as MaxValue <from <TABLE> where <CLAUSE>
Thanks. :)|||TOp n gives u the number of rows.
Max gives u the maximum value in the column|||Originally posted by cyrus
TOp n gives u the number of rows.
Max gives u the maximum value in the column
That is not quite correct...
TOP n gives you the first n rows of the resultset, so TOP 1 is the same as MAX as long as the order is on the same field.|||Originally posted by Bascy
That is not quite correct...
TOP n gives you the first n rows of the resultset, so TOP 1 is the same as MAX as long as the order is on the same field.
i am saying the same thing without order by
Wednesday, March 7, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment