-- Type returned by the crosstab function
CREATE TYPE weekly_sim_submit_count_crosstab AS (
  group_name    text,
  transport     bigint,
  lice          bigint,
  virus         bigint,
  watercontact  bigint,
  sedimentation bigint
);

-- Cross tab function we can call on the materialized view of weekly submit counts
CREATE OR REPLACE FUNCTION crosstab_weekly_sim_submit_count(text)
  RETURNS setof weekly_sim_submit_count_crosstab
  AS '$libdir/tablefunc','crosstab' LANGUAGE C STABLE STRICT;


