How I will use the one of the output column name in same SQL statement for sum calculation

29 Views Asked by At
select 
    nodw as "node ID",
    riskvale as "TotalRis",
    (portvalue - marvalue) as "TotalMarValue" 
    --{ Here I want to take the upper column value i.e ""TotalRis"" / "TotalMarValue" * 100 } as "total Uses"**
from 
    abc

I want to use the output of "TotalRis" and "TotalMarValue" column to get the output for other column. I tried with @{TotalRis} but query not getting execute.

1

There are 1 best solutions below

0
eshirvana On

you can't use alias , as they are the last part of the query that query engine will parse, so :

select 
    nodw as "node ID",
    riskvale as "TotalRis",
    (portvalue - marvalue) as "TotalMarValue", 
    riskvale / (portvalue - marvalue) * 100  as "total Uses"
from abc