Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Coluna de retorno do Oracle SQL calculada a partir de colunas 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