简体   繁体   中英

SQL Calculate Standard Deviation of count using window functions

Calculate Standard Deviation of count of claims using window functions. I'm trying to find members whose standard deviation of count(ClaimNumber) is greater than 3. I do not want to use subqueries, is there a way to perform this using window functions? Unfortunately window functions are not allowed in where clause.

SELECT STDEV(COUNT(ClaimNumber)) OVER (ORDER BY Mbr_ID) AS STD_DEV
FROM myTable
WHERE Prod =91829 

Start with working code:

SELECT STDEV(cnt)
FROM (SELECT member_id, COUNT(ClaimNumber) as cnt
      FROM myTable
      WHERE Prod =91829 
      GROUP BY member_id
     ) m;

I cannot think of a sensible way to do this with window functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM