i have pasted an image with wat o/p i need hope tht helps
I am trying to calculate the percentage of individual rows with total of one particular column.
I am able to achieve it in the SELECT
statement with alias name but I have further calculation with the help of column per
where I derive other columns, so I need this to be in an UPDATE
query. I tried the below query but am getting the error:
Invalid operation: subquery must return only one column
I don't have any unique id. I cannot use IN
statements in this.
Where am I going wrong?
UPDATE a
SET per = (SELECT DISTINCT
code,
p,
pd,
ratio_to_report(SUM(amnt)) OVER (PARTITION BY p) AS per
FROM a
GROUP BY code,p,pd
)
WHERE per IS null;