sql >> Base de Datos >  >> RDS >> Oracle

Columna de retorno de Oracle SQL calculada a partir de columnas existentes

  • Usar 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