How do I select the longest 'string' from a table when grouping

后端 未结 5 2054
北海茫月
北海茫月 2020-12-23 15:45

Example:

SELECT partnumber, manufacturer, condition, SUM(qty), AVG(price), description FROM parts

WHERE [something]

GROUP BY partnumber, manufacturer, cond         


        
5条回答
  •  北海茫月
    2020-12-23 16:16

    ORDER BY LENGTH(description) DESC LIMIT 1
    

    This will sort the results from longest to shortest and give the first result (longest.)

提交回复
热议问题