Oracle
 sql >> Database >  >> RDS >> Oracle

Colonna di ritorno Oracle SQL calcolata da colonne esistenti

  • Utilizza CTE
with data as (

select 
t1.name, 
(select count(*) from t2 where t2.name = t1.name) X, 
(select count(*) from t3 where t3.name = t1.name) Y
from t1
)

select 
data.*,
data.x/data.y as new_calculation
from data