在使用grouping
(与grouping sets
一起使用时,有什么方法可以使用二进制表示法写整数吗?
例如,我想写
select
case grouping(A, B, C, D)
when 0x0011 then 'ONLY AB' --
when 0x0101 then 'ONLY AC'
else 'ABCD'
end as label,
count(*) as statements,
from T
group by grouping sets ((A, B, C), (A, B), (A, C), (A))
代替
select
case grouping(A, B, C, D)
when 3 then 'ONLY AB'
when 5 then 'ONLY BD'
else 'ABCD'
end as label,
count(*) as statements,
from T
group by grouping sets ((A, B, C), (A, B), (A, C), (B, D), (A))
答案 0 :(得分:3)
Presto不支持base-2文字,但是您可以使用from_base
:
SELECT from_base('1101', 2);