3

我正在使用 Oracle RightNow,它使用 MySQL,但不能有嵌套查询,只能选择(双关语!)数量的命令供我使用:http ://documentation.custhelp.com/euf/assets/devdocs/august2016/Connect_PHP /Content/Connect%20for%20PHP%20API/RightNow%20Object%20Query%20Language/ROQL%20and%20Common%20Objects.htm

不允许使用 CASE 语句

假设我有

Select Count(*) as Amount, Category 
From MyTable
Group by Category

一切都很好,我得到一张如下表

Amount | Category
---------------------
1      | Contact Editor
4      | Incident Editor
787    | Raise a Request
78     | Pending Information

我将如何修改我的查询,以便我可以合并前两行以获得一个新的更新表

Amount | Category
---------------------
5      | Editor
787    | Raise a Request
78     | Pending Information

谢谢

4

2 回答 2

1

尝试使用case表达式进行分组:

select Count(*) as Amount,  case when Category in('Contact Editor', 'Incident Editor') then 'editor' else Category end
From MyTable
Group by case when Category in('Contact Editor', 'Incident Editor') then 'editor' else Category end
于 2017-05-22T20:18:58.387 回答
1
select count(*), 
case when Category like '%Editor' then 'Editor' else Category end as Category
From MyTable
Group by Category
于 2017-05-22T20:22:17.977 回答