mysql - SQL Order by Letters Ascending and Numbers Descending Same Column -
i trying sort column via mysql. sort should ascending letters descending numbers. might bit confusing here example:
data sorted:
access 2003 access 2007 access 2013 aliens excel 2003 excel 2007 happy powerpoint 2003 powerpoint 2007
becomes
access 2013 access 2007 access 2003 aliens excel 2007 excel 2003 happy powerpoint 2007 powerpoint 2003
also point out fields in question follow same pattern above: name followed year after space. if isn't possible using built in mysql function. potentially split field 2 fields after first space , sort number first actual field itself?
you can use code separate field in 2 fields , order them required.
select substring_index(substring_index(fullname, ' ', 1), ' ', -1) string_name, trim( substr(fullname, locate(' ', fullname)) ) numberpart table
Comments
Post a Comment