我有给定格式的数据集这是一个月级数据以及每个月的工资.我需要计算每个月结束时的累积工资.我怎样才能做到这一点
+----------+-------+--------+---------------+
| Account | Month | Salary | Running Total |
+----------+-------+--------+---------------+
| a | 1 | 586 | 586 |
| a | 2 | 928 | 1514 |
| a | 3 | 726 | 2240 |
| a | 4 | 538 | 538 |
| b | 1 | 956 | 1494 |
| b | 3 | 667 | 2161 |
| b | 4 | 841 | 3002 |
| c | 1 …Run Code Online (Sandbox Code Playgroud) 我的问题类似于redshift:在窗口分区上计算不同的客户,但我有一个滚动窗口分区。
我的查询看起来像这样,但不支持Redshift中的 COUNT 内的不同查询
select p_date, seconds_read,
count(distinct customer_id) over (order by p_date rows between unbounded preceding and current row) as total_cumulative_customer
from table_x
Run Code Online (Sandbox Code Playgroud)
我的目标是计算截至每个日期的唯一客户总数(因此是滚动窗口)。
我尝试使用dense_rank()方法,但它会失败,因为我不能使用这样的窗口函数
select p_date, max(total_cumulative_customer) over ()
(select p_date, seconds_read,
dense_rank() over (order by customer_id rows between unbounded preceding and current row) as total_cumulative_customer -- WILL FAIL HERE
from table_x
Run Code Online (Sandbox Code Playgroud)
任何解决方法或不同的方法都会有所帮助!
编辑:
输入数据样本
+------+----------+--------------+
| Cust | p_date | seconds_read |
+------+----------+--------------+
| 1 | 1-Jan-20 | 10 |
| 2 …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译Protoc库,但即使它存在,它仍然不断提示我No Such Directory错误
我正在遵循Google的Photobuf编译步骤,也已将Protoc添加到PATH环境变量中。
但是它根本看不到object_detection / protos目录
protoc object_detection/protos/*.proto --python_out=.
Run Code Online (Sandbox Code Playgroud)
目录和文件显然在那里