有没有一种方法可以找到特定组在2天不同天之间的百分比差异?

时间:2019-08-21 20:32:23

标签: sql

我需要计算表中特定组2天之间的百分比差异。

我需要在Error compiling to JavaScript: main.dart:2:6: Error: This requires the 'non-nullable' experiment to be enabled. 天与20190731天之间使用[值]列在字段[FUND]中更改[组]列的百分比。在我的示例中,应为20190628

enter image description here

1 个答案:

答案 0 :(得分:0)

我希望这对您有用:

select prd, grp, 100.0 * (sum(end_value) - sum(start_value)) / sum(start_value)
from
    (
    select prd, grp,
        (case when date = "20190731" then val else 0 end) as end_value,
        (case when date = "20190628" then val else 0 end) as start_value
    from table1
    ) as t
group by prd, grp