我正在寻找使用 db2 的总和。显然,我收到了 -204 错误,因为我正在尝试使用别名来计算聚合。我不知道如何解决这个问题,希望能得到一些帮助。
SELECT
DA.AMOUNT,
cast(sum(cast(FAT.TRANSACTION_AMOUNT as real)) as integer) as time_used,
(DA.AMOUNT - sum(FAT.TRANSACTION_AMOUNT)) as time_to_use,
concat(((sum(FAT.TRANSACTION_AMOUNT)/DA.AMOUNT)*100),'%') AS Percentage_used,
**sum(time_used)/SUM(DA.AMOUNT) AS Total_Percentage_Used**
FROM FACT_Table as FAT
RIGHT DIM_AWARD DA ON FAT.DIM_ID = DA.DIM_ID
group by DA.AMOUNT