Invantive 문서Invantive Cloud의 일부
Invantive 지원 포럼로그인 / 회원가입

Stddev 집계 함수

구문

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart TD
    stdDevAggregateFunction_start((START))
    stdDevAggregateFunction_start --> stdDevAggregateFunction_0_0[STDDEV]:::quoted
    stdDevAggregateFunction_0_0 --> stdDevAggregateFunction_0_1["("]:::quoted
    stdDevAggregateFunction_0_1 --> stdDevAggregateFunction_0_2[DISTINCT]:::quoted
    stdDevAggregateFunction_0_1 --> stdDevAggregateFunction_0_2a[ALL]:::quoted
    stdDevAggregateFunction_0_2a --> stdDevAggregateFunction_0_3
    stdDevAggregateFunction_0_2 --> stdDevAggregateFunction_0_3[<a href="Invantive UniversalSQL/Grammar/Expression" class="internal-link">expression</a>]
    stdDevAggregateFunction_0_3 --> stdDevAggregateFunction_0_4[")"]:::quoted
    stdDevAggregateFunction_0_4 --> stdDevAggregateFunction_end((END))

목적

숫자 값들의 그룹에서 표준편차를 구하는 그룹 함수입니다. 모집단 표준편차는 다음과 같이 계산됩니다: 평균에서 각 값의 편차를 제곱한 합을 값의 개수로 나눕니다. 값이 하나뿐인 그룹의 결과는 0입니다. DISTINCT를 지정하면 각 고유 값이 한 번씩만 포함됩니다. ALL이(가) 기본값이며, 각 값은 발생한 횟수만큼 계산됩니다. ALL은(는) 릴리스 28.0부터 사용할 수 있습니다.

예시

다음 예는 도매 고객의 미결 잔액에 대한 표준편차를 계산합니다. 예를 들어 세그먼트 내에서 신용 위험이 얼마나 고르게 분포되어 있는지 판단하기 위한 것입니다:

select stddev(cus.balance)
from   csvtable
       ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000'
         row delimiter '|'
         column delimiter '#'
         columns name         varchar2 position next
         ,       segment      varchar2 position next
         ,       balance      number   position next
         ,       credit_limit number   position next
       ) cus
where  cus.segment = 'Wholesale'

-------------------
2500

다음 예는 잔액이 없는 고객을 제외하고, 고객 세그먼트별 미결 잔액의 표준편차를 계산합니다:

select cus.segment
,      stddev(cus.balance)
from   csvtable
       ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000'
         row delimiter '|'
         column delimiter '#'
         columns name         varchar2 position next
         ,       segment      varchar2 position next
         ,       balance      number   position next
         ,       credit_limit number   position next
       ) cus
where  cus.balance is not null
group
by     cus.segment
order
by     cus.segment

-------------------
Manufacturing    6250
Wholesale        2500