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

Contar el número de valores por id.

Haz un GROUP BY , usa COUNT (que solo cuenta valores no nulos):

select id,
       count(value1) as value1,
       count(value2) as value2,
       count(value3) as value3
from table1
group by id

Editar :

Si los valores no son nulos sino '.' (o algo más), use case expresiones para hacer conteo condicional, algo como:

select id,
       count(case when value1 <> '.' then 1 end) as value1,
       count(case when value2 <> '.' then 1 end) as value2,
       count(case when value3 <> '.' then 1 end) as value3
from table1
group by id