November 16, 2009 at 4:35 am
Hi,
What is result of the query if i use max function for the field which datatype is varchar
Ex:
Select Max(sname) from Student
November 16, 2009 at 4:57 am
You will get the student with last character of your alphabet, probably Z.
Zanzibar is MAX over Sweden. It's the way they are sorted.
N 56°04'39.16"
E 12°55'05.25"
November 16, 2009 at 4:57 am
hi
its simply returns the last sname in alphabetical order....
Its something similar to
select top 1 sname from students order by sname desc
November 16, 2009 at 1:12 pm
To be a little more specific:
to find the max sname is like searching for the largest ASCII value of the first position of sname, continues moving to the right for ties.
SELECT max(sname) from(
select char(8) + 'Zanzibar' AS sname UNION ALL
select 'Zanzibar' UNION ALL
select 'zanzibar' UNION ALL
select ' Zanzibar' UNION ALL
select '_Zanzibar' UNION ALL
select '1Zanzibar' UNION ALL
select '9anzibar' UNION ALL
select '~anzibar') t
November 16, 2009 at 6:51 pm
The sorting order is defined by the collation used.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy