I have a large table in mysql with 150 columns (not my design)
and Im working on finding the population of each column (not empty string)
I have a table
email | fname | lname | ... | ... | aaa | bbb | ccc | rrr | qqq | bbb | eee | '' | ddd | bbb | ... | ... | '' | ccc | eee |
desire result (format does not matter actually)
fields | # population | % population email | 1501203 | 100 fname | 1450000 | 95 lname | ... | .... ...
my code so far
SELECT 'email' as col1 ,COUNT(NULLIF( Email, '' )) as '#Populated' , (COUNT(NULLIF( Email, '' )) * 100/ (Select count(*) from mytable)) as '% pupolation' FROM mytable union SELECT 'fname'... *repeat code above 150 times...*
is there a better way to do this?
i dont necessarily need to list the column names in 1 column, it just looks nicer