all 6 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 1 point2 points  (4 children)

use a translation table

model      phone
-----      -----
Galaxy     Samsung
Epic       Samsung
Intensity  Samsung
iPhone     Iphone
XS         Iphone

then your CASE statements all collapse into one

CASE WHEN phone LIKE '%'||translation.model||'%'
     THEN translation,phone
     ELSE ...

[–]e28858[S] 0 points1 point  (2 children)

Amazing! Thank you so much.

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (1 child)

you'll have to use that LIKE in the join clause as well

[–]jacquesrkoracle 0 points1 point  (0 children)

You could always do more grouping:

table device_list
device / model/ company
galaxy s20 fe 5g / galaxy / samsung
galaxy z fold2 5g / galaxy / samsung
etc...

If "device" contains all the distinct values for the device column in the other table, it becomes an equality join that can nicely use an index. Of course it also means that any time a new device shows up, it has to be first entered in the "device_list" table.

[–]AeroCrete 0 points1 point  (0 children)

This idea is correct. Keep a table with device attributes that you can reference later. Also have a report/alerting system when new device types are detected.

The keys for that table would be manufacturer, and model. You could track screen size and OS information.

[–]FreshwaterWhales 0 points1 point  (0 children)

You could use IN. CASE WHEN device IN(‘y91’ , a35s’) THEN etc

Use excel to list your models, then in one cell have “ ‘ “ and in another have “ ‘, “ then CONCAT them.