在表格存储中想通过月份分组得到相应统计聚合数据,请问大家有效率高点的替代方案吗?
select
case
when news_star_time>=1690819200 and news_star_time<1693497600 then '2023-08'
when news_star_time>=1693497600 and news_star_time<1696089600 then '2023-09'
when news_star_time>=1696089600 and news_star_time<1698768000 then '2023-10'
when news_star_time>=1698768000 and news_star_time<1701360000 then '2023-11'
when news_star_time>=1701360000 and news_star_time<1704038400 then '2023-12'
when news_star_time>=1704038400 and news_star_time<1706716800 then '2024-01'
when news_star_time>=1706716800 and news_star_time<1709222400 then '2024-02'
when news_star_time>=1709222400 and news_star_time<1711900800 then '2024-03'
when news_star_time>=1711900800 and news_star_time<1714492800 then '2024-04'
when news_star_time>=1714492800 and news_star_time<1717171200 then '2024-05'
when news_star_time>=1717171200 and news_star_time<1719763200 then '2024-06'
when news_star_time>=1719763200 and news_star_time<1722441600 then '2024-07'
when news_star_time>=1722441600 and news_star_time<1725120000 then '2024-08'
when news_star_time>=1725120000 and news_star_time<1727712000 then '2024-09'
end as time,
count(*) as cishu,
sum(news_zbje) as jine
from
table_name
where
news_type=1
and news_star_time between 1690819200 and 1725120000
and news_xingzi <> '-'
and new_Industry_father <> '99'
group by
time
order by
time ASC
limit 30
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。