Results 1 to 2 of 2

Thread: select 4 rows, calculate stddev, take next 4 rows, calculate stddev

  1. #1
    Join Date
    Jun 2004
    Posts
    19

    select 4 rows, calculate stddev, take next 4 rows, calculate stddev

    Hello,

    I'd like to do some statistic calculations.
    For example to select the first 4 values from emp.sal, calculate STDDEV and VARIANCE, MIN
    and MAX from these values,
    than take the next 4 values from emp.sal, calculate STDDEV,VARIANCE,MIN,MAX,
    than take the next 4 values and so on..

    How can this be done ?

  2. #2
    Join Date
    Jun 2004
    Posts
    19
    Ok, problem solved:

    select
    FLOOR((rank-1)/4) Srno,
    VARIANCE(sal),
    stddev(sal),
    MIN(sal),
    MAX(sal)
    FROM
    (
    select
    empno,
    ename,
    sal,
    ROWNUM rank
    FROM
    Emp
    ) Tab1
    GROUP BY
    FLOOR((rank-1)/4);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •