ansi sql - Longest value of a data in a column -


query display name of user(s) having longest name, sorted name of user. please note there may leading or trailing spaces in names of users.

i tried following query:

select name, max(length(trim(name))) length  user  group name  order name; 

but gives me length of values of name column without spaces.

but need values have maximum length.

suppose there 15 names in column , there 5 names of longest length, 5 names , corresponding length.

table name: user

column name , datatype:

name varchar(255) 

select * users length(trim(name)) = (select max(length(trim(name))) users) order name 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -