I'm trying to write my first crosstab query in Postgres. Some of the results have no entries and so the rows that are returned have null entries. How do I set a default value for those entries?
Here is a row that is returned:
-[ RECORD 1 ]-------------------+-----
username | some name
some_column_name_1 | 2
some_column_name_2 |
Here is my crosstab query:
SELECT *
FROM crosstab( 'select username, stage, count from some_view order by 1,2')
AS final_result(username TEXT,
"some_column_name_1" BIGINT,
"some_column_name_2" BIGINT,
);
I've tried little things like this with no luck:
"some_column_name_1" BIGINT 0
"some_column_name_1" BIGINT default 0
"some_column_name_1" BIGINT set default 0
CREATE TABLE
statements for the tables in question adding the desired output. Those answering need a Minimal, Complete, and Verifiable example. Use formatted text please, no screen shots.