我认为这与您所描述的相似(此处不包括一天,但您会明白的):
declare global temporary table session.stores_sales_indicators
(
store_number integer not null,
sales integer not null
)
on commit preserve rows with norecovery, structure=x100;
insert into session.stores_sales_indicators
values(1,100),(1,200),(2,500),(2,50),(3,50),(3,300);
select
store_number,
sum(sales) as sales,
rank() over (order by sum(sales) desc) as rank
from session.stores_sales_indicators
group by store_number;
另请参阅精美手册,这是分析函数部分的链接:
https ://docs.actian.com/vector/5.1/index.html#page/SQLLang%2FAnalytical_Functions.htm