Currently using Postgres 9.1. I'm looking for a way to get the count for every column in a specific table. It has around 600 columns and looks like this:
CREATE TABLE geoproject.mes_wastab (
invid character varying(16)
, invtype character varying(3)
, smpid integer
, smpname character varying(40)
, smpdate date
, smptime character varying(5)
, o2st_p double precision
, wspgokna double precision
, o2_p double precision
, absenkungs double precision
, klarstrom3 double precision
, ...
);
Column names should be queried from information_schema.columns
. Not-null values should be counted. The result should look like this:
column_name : count
Can I query this with SQL, or do I need a function?