我能够在另一个查询中使用我尝试制作的类似图表正常工作,但是,这次我无法让它正常工作。有什么我可能遗漏的东西,还是我试图朝着错误的方向前进?我基本上是在尝试对图表进行排序,以便总“按服务”(加急、地面、地面加)在组内按降序排序,然后在 x 轴上对图表进行排序,从 2 天到 6 天。在屏幕截图中,3、4、5 对条形图进行了正确排序(从高到低),但 2 不是。
select order_number,
cnt,
(case service
when 'DHLSmartMailParcelPlusExpedited' then 'Expedited Plus'
when 'DHLSmartMailParcelExpedited' then 'Expedited'
when 'DHLSmartMailParcelGround' then 'Ground'
when 'DHLSmartMailParcelPlusGround' then 'Ground Plus'
END),
days_since_packed
from (
select ss.*,
dense_rank() over (order by service_count desc, service) as seqnum
from (
select service,
count(*) as cnt,
days_since_packed,
sum(count(*)) over (partition by service) as service_count
from countservice
group by 4) ss
) ss
order by service_count, days_since_packed, service;