MySQL: select top result in a group of distinct(char_length(text_column)) records -


i have group of records these following notional results. there multiple occurrences number in count column repeated. 'count' comes char_length(text_column). want grab first record in each such grouping. how do this?

i've looked @ char_length() documentation , searched examples has been done, can't find anything.

select distinct(char_length(text_column)), text_column table 

.... close -- not close -- i've been able result.

=======+============================  count +      text_column =======+============================ 2139   + text entry -------+---------------------------- 3000   + sentence here -------+---------------------------- 3000   + more text in sentence -------+---------------------------- 3000   + still more text here -------+---------------------------- 

thank you, bw

there no such thing "first" unless column specifies ordering. can, however, value indeterminate row using group by:

select char_length(text_column), text_column table group char_length(text_column); 

i'm not big fan of using mysql extension group by text_column allowed in select, not group by. however, because long column, might more efficient let mysql pick value rather using actual aggregation function (such min() or max()).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -