These bits do not seem reliable enough to me:
WHEN group_concat(o.option_code) LIKE '%111%' ... WHEN group_concat(o.option_code) LIKE '%112%' ...
LIKE '%111%' will match, for example. '111222, 145, 166, 188' is the same as '111, 145, 166, 188' . Unless, of course, there are only three-character codes, and you do not expect this to change soon.
However, I would probably use a different technique, most likely a conditional COUNT or SUM. For instance:
(CASE WHEN SUM(o.option_code = '111') > 0 THEN 'Auto' WHEN SUM(o.option_code = '112') > 0 THEN 'Manual' ELSE 'Other' END) AS Transmission
Please also note that in your particular case, the following, although rather specific, solution should work:
IFNULL( MIN(CASE o.option_code WHEN '111' THEN 'Auto' WHEN '112' THEN 'Manual' END), 'Other' ) AS Transmission
those. if '111' or, for some reason, both '111' and '112' are found among codes in the same group of lines, MIN() will return 'Auto' , if '112' bot not '111' , it will be evaluated to 'Manual' . Otherwise, it will be NULL, in which case the IFNULL() function will evaluate to 'Other' .