我有以下查询,我正在尝试加入两个分组列的语句。
.*
我收到的错误是无法识别内部'内部的输入。 '加盟' ('声明
答案 0 :(得分:1)
不确定您要执行的操作,但cte后面应该是另一个cte或select
,insert
。
您可以使用
select name, title,
max(case when special = 'super' then max_power end) as Super_max,
max(case when special = 'awesome' then max_power end) as Awesome_max,
min(case when special = 'super' then max_power end) as Super_min,
min(case when special = 'awesome' then max_power end) as Awesome_min
from mytable
group by name, title
如果列名必须相同,请使用union all
。
select name, title,
max(case when special = 'super' then max_power end) as Super,
max(case when special = 'awesome' then max_power end) as Awesome
from mytable
group by name, title
union all
select name, title,
min(case when special = 'super' then max_power end) as Super,
min(case when special = 'awesome' then max_power end) as Awesome
from mytable
group by name, title