我有一个如下数据库
+------------+---------------------------------------+--------+
| sender | subject | day |
+------------+---------------------------------------+--------+
| Darshana | Re: [Dev] [Platform] Build error | Monday |
| Dushan A | (MOLDOVADEVDEV-49) GREG Startup Error | Monday |
+------------+---------------------------------------+--------+
我想使用上表获得结果。它应该检查主题是否包含给定的单词,然后在给定日期的那个单词列中添加一个。
|Day | "Dev" | "startup"|
+---------+------------+----------+
| Monday | 1 | 2 |
| Friday | 0 | 3 |
我被认为使用了DECODE功能,但我无法获得预期的结果。
答案 0 :(得分:2)
您可以使用条件聚合执行此操作:
select day, sum(subject like '%Dev%') as Dev,
sum(subject like '%startup%') as startup
from table t
group by day;