lundi 29 décembre 2014

How to see percentage of existing values for all columns in mysql table?


I have three large-ish tables (~20 columns each) and I want to know what percentage of rows have a value for each column.


For instance, this table:



ID | TITLE | SERVING | NOTE
-------------------------------------------------------------------
6716 | Yummy Molasses ... | 1 cookie |
3765 | Rosemary-Red Wi... | |
5178 | Stuffed Avocado... | |
6025 | Amazing Pea Sou... | about 1 cup |
4412 | Overnight Oatme... | 1 cup | Note: Steel-cut oats...


Might yield results similar to this:



ID | TITLE | SERVING | NOTE
-------------------------------------------------------------------
100% | 100% | 60% | 20%


This is for an internal report, so the format isn't too important. If I only have the count() instead of the percent, that's fine. Having the column name would be nice, but not necessary. Etc.


I'm not very familiar with queries that involve more meta questions like gathering table names or working over all the columns in a table, so I'm interested to see what people suggest.





Aucun commentaire:

Enregistrer un commentaire