0

すべて、次の Sequel クエリを使用しています...

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

...約 1,000 行で次のようなデータのテーブルをレンダリングするには:

| 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   |

ただし、使用可能な原色タグ (赤、青、黄など) の数が限られていることがわかっているため、Sequel クエリを微調整して、原色タグでグループ化する (そして表に原色タグ列を追加する) 方法はありますか?レンダリングする...

 | 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            | 

このフォーラムで、一見関連性のある解決策を持つ同様の質問を見つけましたが、それらのロジックをつなぎ合わせて、求めている表を再現することができませんでした。どんな洞察も大歓迎です!

4

0 に答える 0