All, I'm using the following Sequel query...
select
u.full_name, u.id, sum(hit_count), tag_names
from MyTable as t
inner join MyUsers as u on u.id=t.user_id
where t.created_at >= '2015-1-01 04:00:00' AND t.created_at < '2015-2-01 04:00:00' AND tag_names like '%Tree%'
group by u.id
...to render a table of data that looks like this with about 1,000 rows:
| full_name | id | sum(hit_count) | tag_names |
| Fred Johnson | 001 | 1500 | Tree, Apple, Blue, Banana |
| Joe Smith | 002 | 663 | Tree, Red, Pear, Yellow |
| Tina Cook | 001 | 1500 | Tree, Berry, Red, Grape |
| Kyle Cross | 001 | 1500 | Tree, Berry, Red, Grape |
However, because I know the finite number of primary color tags (e.g. Red, Blue, Yellow) available, is there a way to tweak my Sequel query to also group by primary color tag (and add a primary color tag column to my table) to render...
| full_name | id | sum(hit_count) | tag_names | Primary_Color_Tag |
| Fred Johnson | 001 | 1500 | Tree, Apple, Blue, Banana | Blue |
| Joe Smith | 002 | 500 | Tree, Red, Pear, Yellow | Red |
| Tina Cook | 001 | 1500 | Tree, Berry, Red, Grape | Red |
| Kyle Cross | 001 | 1500 | Tree, Berry, Red, Grape | Red |
| Joe Smith | 001 | 163 | Tree, Red, Pear, Yellow | Yellow |
I've found similar questions on this forum that have seemingly relevant solutions, but I've been unable to piece together their logic to reproduce the table I'm after. Any insight would be greatly appreciated!