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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -