Calculating skewness of a data distribution in SQL

2019-09-15 04:01发布

问题:

I have a dataset in an Access database that, for simplicity's sake, looks like this:

      ID     Group   Employee       Ticket ID
    ------ --------- -------- -----------------
      1        A       Joe           123414
      2        A       Joe           12309124
      3        A       Bob           112321321
      4        A       Bob           213123214142
      5        A       Sam           123214214124
      6        B       Jen           412949218419
      7        B       Amy           12341234213

What I'm trying to do is calculate the statistical skewness of distribution of the number of tickets each employee has handled.

In a perfect world, my SQL would be this:

SELECT
    [Group], SKEW([myCount]) AS mySkew
FROM
    (
     SELECT [Group], [Employee], COUNT(*) AS myCount
     FROM MyTable
     GROUP BY [Group], [Employee]
    )
        AS TempTable
GROUP BY
   [Group];

However, it appears that Access does not have a SKEW function. Anyone know how I can do this calculation?

回答1:

It looks like somebody has tried this and created a small library for it here:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_2529-Median-Mode-Skewness-and-Kurtosis-in-MS-Access.html