我想使用PrestoDB found for SQL Server进行以下操作?
https://test.com/images/images/120/1313131313232.jpg
https://test.com/images/images/120/1313131313233.jpg
...
...以便得到这样的结果:
select t.range as 'latency', count(*) as 'Total'
from (
select case
when latency between 0 and 0.250 then 'Fast'
when latency between 0.250 and 1.0 then 'Normal'
when latency between 1.0 and 2.0 then 'Elevated'
else 'High'
end as range
from myprestodb.mytable) t
group by t.range
答案 0 :(得分:1)
您可以尝试:
select range as Latency, count(*) as Total
from (
select case
when latency > 0 and latency <= 0.250 then 'Fast'
when latency > 0.250 and latency <= 1.0 then 'Normal'
when latency > 1.0 and latency <= 2.0 then 'Elevated'
else 'High'
end as range
from myprestodb.mytable
)
group by range
答案 1 :(得分:0)
您可以使用count_if
提供每列计数的条件。这正是我想要的:
select count_if(latency < 0.25) as "Fast: < .25",
count_if(latency > 0.25 and latency <= 1.0) as "Normal: .25 - 1",
count_if(latency > 1.0 and latency <= 2.0) as "Elevated: 1 - 2",
count_if(latency > 2.0) as "High: > 2"
from myprestodb.mytable
...