Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3b8898 commit 9ae9b41Copy full SHA for 9ae9b41
coderd/database/queries/insights.sql
@@ -95,10 +95,19 @@ WITH d AS (
95
), template_ids AS (
96
SELECT
97
from_,
98
- array_agg(DISTINCT template_id) AS ids
99
- FROM usage_by_day, unnest(template_ids) template_id
100
- WHERE template_id IS NOT NULL
101
- GROUP BY from_, template_ids
+ array_agg(DISTINCT id) AS ids
+ FROM (
+ SELECT from_, unnest(ids) AS id
102
+ SELECT DISTINCT
103
+ from_,
104
+ array_agg(DISTINCT template_id) AS ids
105
+ FROM usage_by_day, unnest(template_ids) template_id
106
+ WHERE template_id IS NOT NULL
107
+ GROUP BY from_, template_ids
108
+ ) AS template_usage_by_day_unnested
109
+ ) AS template_usage_by_day
110
+ GROUP BY from_
111
)
112
113
0 commit comments