January 19, 2012 at 6:04 am
hi,
max function returns maximum no. from that table
but if it is terms of string name what it should return?
select max(name) from mytable??
January 19, 2012 at 6:10 am
it would return strings that start with the highest ascii value;
i would expect it to return a string that starts with the letter "z" if it existed, and if there were more than one string that started with 'z', it would return the longer string that has the highest starting letters.
for example, on my SLQ2008 instance, i have 3 strings that all match the same beginning chars:
xp_ora2ms_exec2
xp_ora2ms_exec2_ex
xp_ora2ms_versioninfo2
the max ends p being xp_ora2ms_versioninfo2, because at the 11th character for comparison, the letter "v" has a higher ascii value than "e"
select MAX(name) from sys.objects
select name from sys.objects where LEFT(name,2) = 'xp'
select MAX(name) from sys.objects where name not like '%version%'
Lowell
January 19, 2012 at 6:12 am
Thank you so much
January 19, 2012 at 6:40 am
ashuthinks (1/19/2012)
max function returns maximum no. from that table
Close but not exactly what it does, if we define the function as max(expression) then the max() function returns the maximum value in the expression - no matter the data type.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply