cjard
April 27th, 2007, 02:21 PM
Any comments on the best way to do a multi level average like this?
I'd do it like:
SELECT
org,
avg(cnt_dep)
FROM
(
SELECT
org,
count(*) as cnt_dep
FROM
emp
GROUP BY
org, dep
)
GROUP BY
org
Any other offerings?
I've tried
AVG(COUNT(*) OVER(PARTITION BY org, dep))
but the group function is nested too deeply
I'd do it like:
SELECT
org,
avg(cnt_dep)
FROM
(
SELECT
org,
count(*) as cnt_dep
FROM
emp
GROUP BY
org, dep
)
GROUP BY
org
Any other offerings?
I've tried
AVG(COUNT(*) OVER(PARTITION BY org, dep))
but the group function is nested too deeply