问题如下。我们有两个表子查询(A 和 B)。我需要逐行应用公式
a.Processed / b.Total * 100 并将结果显示在新列“Activity %”中</p>
我尝试了以下查询:
SELECT
(
a.Processed / b.Total * 100
) AS "Activity %"
FROM
(
SELECT
sla_date,
request_type,
CAST(
SUM(sla_value) AS DECIMAL(
10,
2
)
) AS Processed
FROM
table_schema.table_name
WHERE
team = '100'
AND sla_duration_hrs < 480
GROUP BY
sla_date,
request_type
) AS A
JOIN(
SELECT
sla_date,
request_type,
CAST(
SUM(sla_value) AS DECIMAL(
10,
2
)
) AS Total
FROM
table_schema.table_name
WHERE
team = '100'
GROUP BY
sla_date,
request_type
) AS B
ON a.sla_date = b.sla_date
AND a.request_type = b.request_type
但我收到错误
“SQL 错误 [SE001]:拼接引擎异常:为 class.splicemachine.db.impl.sql.compile.FromBaseTable 调用 ISpliceVisitor 访问方法时出现问题”
我可以使用 UNION ALL 来完成这项任务,但真正的表子查询有数百行,而且解决方案远非优雅和省时。
关于如何返工查询的任何想法?
谢谢你。