首页 > 代码库 > SQL语句

SQL语句

1、累计查询,每天的累计,分指标,分日期

主要关注一下:OVER、PARTITION BY

SELECT
INDEX_DAY,INDEX_PLAN_ID,INDEX_VALUE,SUM(INDEX_VALUE) OVER (PARTITION BY INDEX_PLAN_ID ORDER BY INDEX_DAY) SUM_VALUE
FROM
DW_INDEX_DAY
WHERE
INDEX_PLAN_ID
IN
(‘H03000100‘,‘H03000107‘)

SQL语句