mardi 28 avril 2015

Count frequency of a value per column, displaying results for all columns with blanks filled

I have a large SQL database which looks like this:database layout

For a single column, I would count frequency with the command:

SELECT col1,count(1) FROM tbl GROUP BY col1;

to give something which looks like this: output for a single column

But ideally, I would want a command which ran the above over all specified columns, matching on the Value column, and filling the blanks out with 0. Is this possible in any SQL implementation? Im currently using SQLite, but we're in a fairly open relationship.

This is my 'desired' output: enter image description here

Aucun commentaire:

Enregistrer un commentaire