Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ae9b41

Browse files
committed
WIP
1 parent c3b8898 commit 9ae9b41

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

coderd/database/queries/insights.sql

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,19 @@ WITH d AS (
9595
), template_ids AS (
9696
SELECT
9797
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
98+
array_agg(DISTINCT id) AS ids
99+
FROM (
100+
SELECT from_, unnest(ids) AS id
101+
FROM (
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_
102111
)
103112

104113
SELECT

0 commit comments

Comments
 (0)