If I have a table with columns A through C (this is just an example) and I have many entries that populates these tables, entries may be Null
ex:
A | B | C
1 | 2 | 6
1 | 4 | Null
1 | 0 | Null
how can i write a query that woulld output:
– My column names as rows
– a count of number of null entries for each column
– a minimun / maximum / average for each column
i.e:
A | 0 | 1 | 1 | 1
B | 0 | 0 | 4 | 2
C | 2 | 6 | 6 | 2
where
- 2nd column is the number of NULL entries
- 3rd is the minimum
- 4th is the max
- 5th is an average of all entries for that column
I apprecaite any help you can give me!!
write three queries, each GROUPed BY a single column, and produce the data needed for the column in the query
be sure to add the columnName as a literal in the SELECT statements
UNION the three queries together and order by columnName
EDIT:
another option would be to push columnName and value to a temp table for each column and then the query with the aggregate functions becomes simple…
use a spreadsheet to create your 50 INSERT statements, and then, as I said above, the aggregate query should be simple