Add the crosstab select used in grafana

This commit is contained in:
2025-11-18 15:32:08 +01:00
parent 87dd246d09
commit 74600abddc
@@ -0,0 +1,24 @@
-- Pivots the sim count to use the sim kinds as columns. This is what is called
-- in grafana. If we get more sim kinds, they must be added here, and also in grafana.
--
-- group_name | transport | lice | virus | watercontact | sedimentation
-- --------------+-----------+------+-------+--------------+---------------
-- @mowi.com | 1 | | | |
-- @oceanbox.io | 1 | 1 | 5 | 6 |
-- @scaleaq.com | 7 | | | |
-- (3 rows)
SELECT
*
FROM
crosstab_weekly_sim_submit_count(
'SELECT * FROM weekly_sim_submit_count
WHERE sim_type IN (
''transport'',
''lice'',
''virus'',
''watercontact'',
''sedimentation''
)
ORDER BY 1, 2'
)