sql >> Base de Datos >  >> RDS >> Mysql

Cuente las ocurrencias en múltiples columnas

Si solo hay 6 columnas, entonces una forma de hacerlo

select Number, count(*) From (select Number1 as Number from your_table
union all
select Number2 as Number from your_table
union all
select Number3 as Number from your_table
union all
select Number4  as Number from your_table
union all
select Number5  as Number from your_table
union all
select Number6 as Number from your_table) myTab
group by Number;