使用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))
Presto不支持base-2文字,但您可以使用from_base
:
SELECT from_base('1101', 2);