将数据从汇总更改为颗粒水平
我的数据处于形式:
复制:
DROP TABLE IF EXISTS SALARY;
CREATE TEMP TABLE salary
(
Employee varchar(100),
Salary1 numeric(38,12),
Salary2 numeric(38,12)
);
INSERT INTO salary (Employee, Salary1 ,Salary2)
VALUES ('A1',100,300),('A2',200,300),('A3',300,450),('A4',400,600);
我想均匀分配(因为我们将薪金汇总2天的数据汇总到1列中),并将其投入到每日级别的数据中:
因此,如果您看到员工A2-SUM的薪水为第三和4,则可能是300(从第二个表中获得150+150)。 任何帮助/线索都值得赞赏。
My data is in the form:
To reproduce:
DROP TABLE IF EXISTS SALARY;
CREATE TEMP TABLE salary
(
Employee varchar(100),
Salary1 numeric(38,12),
Salary2 numeric(38,12)
);
INSERT INTO salary (Employee, Salary1 ,Salary2)
VALUES ('A1',100,300),('A2',200,300),('A3',300,450),('A4',400,600);
I want to divide it evenly (as we have data for 2 days of salary aggregated into 1 column) and cast it into a daily level data as below:
Hence, if you see for employee A2-Sum of salary for 3rd and 4th may would be 300 (150+150 from the 2nd table).
Any help/leads appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
物质化的日历表随着所需的日期,询问。没有一个,a tally table 或cte(如下示例)是另一种方法。
A materialized calendar table with the desired dates will facilitate generating the dates needed for the query. Without one, a tally table or CTE (as in the below example) is an alternative method.