Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Contar as ocorrências em várias colunas


Se houver apenas 6 colunas, uma maneira de fazer isso
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;