PostgreSQL 9.0.4ʸ�� | ||||
---|---|---|---|---|
前のページ | 巻戻し | 第 9章�ؿ��ȱ黻�� | 早送り | 次のページ |
����ؿ���ʣ���������ͤ���ñ��η�̤�����ޤ��� 表9-42�����表9-43���Ȥ߹��߽���ؿ����ޤ��� ����ؿ����ü�ʹ�ʸ�˴ؤ���ͻ���項4.2.7����������Ƥ��ޤ����ޤ�������Ū�ʾ���ˤĤ��Ƥ�項2.7�Ȥ��Ʋ�������
表 9-42. ���ѽ���ؿ�
�ؿ� | �����Υǡ����� | ����ͷ� | ���� |
---|---|---|---|
array_agg(expression)
| any | ������������ | �����Ϣ�뤵�줿NULL��ޤ������� |
avg(expression)
| smallint, int, bigint, real, double precision, numeric, or interval | �������ΰ����Ǥ��������numeric����ư�������ΰ����Ǥ����double precision������ʳ��ϰ����Υǡ�������Ʊ�� | ���Ƥ������ͤ�ʿ���͡ʻ���ʿ�ѡ� |
bit_and(expression)
| smallint, int, bigint, or bit | �����Υǡ�������Ʊ�� | ���Ƥ���NULL�������ͤΥӥå��ѡ���NULL�������ͤ��ʤ����NULL |
bit_or(expression)
| smallint��int��bigint���ޤ��� bit | �����Υǡ�������Ʊ�� | ���Ƥ���NULL�������ͤΥӥå��¡���NULL�������ͤ��ʤ����NULL |
bool_and(expression)
| bool | bool | ���Ƥ����Ϥ����ʤ�п��������Ǥʤ���е� |
bool_or(expression)
| bool | bool | ���ʤ��Ȥ�1�Ĥ������ͤ����ʤ�п��������Ǥʤ���е� |
count(*) | bigint | ���ϹԤο� | |
count(expression) | ���� | bigint | expression����NULL�ͤ�������ϹԤθĿ� |
every(expression)
| bool | bool | bool_and ������ |
max(expression) | ���Ƥ������͡�ʸ���ޤ������ջ��﷿ | �����η���Ʊ�� | ���Ƥ������ͤˤ錄��expression�κ����� |
string_agg(expression,
delimiter)
| text, text | text | ���Ϥ��줿�ͤ����ꤷ���ǥ�ߥ��Ƕ��ڤ�줿��Ĥ�ʸ�����Ϣ�뤵��ޤ��� |
min(expression) | ���Ƥ������͡�ʸ���ޤ������ջ��﷿ | �����η���Ʊ�� | ���Ƥ������ͤˤ錄��expression�κǾ��� |
sum(expression) | smallint��int��bigint��real��double precision��numeric���ޤ���interval | smallint�ޤ���int���ΰ����Ǥ����bigint��bigint���ΰ����Ǥ����numeric����ư�������ΰ����Ǥ����double precision������ʳ��ϰ����Υǡ�������Ʊ�� | ���Ƥ������ͤ��Ϥ�expression���� |
xmlagg(expression)
| xml | xml | XML�ͤ�Ϣ��� 項9.14.1.7�⻲�ȡ� |
�嵭�δؿ��ϡ�count
�ؿ��������1�Ԥ�����ʤ��ä����NULL�ͤ��֤����Ȥ����դ��Ƥ����������äˡ��Ԥ����ʤ�sum
�ؿ��ϡ�ͽ�ۤ����Ǥ����������ǤϤʤ�NULL���֤���������array_agg
�ϡ����ϹԤ�¸�ߤ��ʤ����ˡ�������ǤϤʤ�NULL���֤��ޤ���ɬ�פǤ���С�NULL���ޤ��϶�����ȸ�����Ū��coalesce
�ؿ���Ȥ����Ȥ��Ǥ��ޤ���
注意:
bool_and
��bool_or
��������ؿ���ɸ��SQL�ν���ؿ�every
��any
�ޤ���some
���б����ޤ���any
��some
�ˤĤ��ƤǤ�����ɸ��ι�ʸ�ˤ�ۣ�椵������褦�Ǥ���SELECT b1 = ANY((SELECT b2 FROM t2 ...)) FROM t1 ...;�����ǡ����䤤��碌�������ͤǤΣ��Ԥ��֤���硢
ANY
�����䤤��碌��Ƴ�������Ρ��⤷���Ͻ���ؿ��Ǥ����Τ����줫�Ȥߤʤ����Ȥ��Ǥ��ޤ��� ���äơ������ν���ؿ���ɸ���̾�����դ��뤳�ȤϤǤ��ޤ���
注意: ¾��SQL�ǡ����١������������ƥ�Ǥκ�Ȥ˿Ƥ�����桼���ϡ�
count
����ؿ����ơ��֥����Τ�Ŭ�Ѥ���������ǽ�˼�˾���뤫���Τ�ޤ���SELECT count(*) FROM sometable;�Τ褦���䤤��碌�ϥơ��֥����Τ��༡���������Ѥ���PostgreSQL�ˤ��¹Ԥ���ޤ���
����ؿ�array_agg
��string_agg
�������xmlagg
������������Υ桼������ν���ؿ��ϡ������ͤν���˰�¸������̣�Τ����̤η���ͤ��������ޤ��������¤ӽ�ϥǥե���ȤǤϻ��ꤵ��ޤ���項4.2.7�˵��Ҥ���Ƥ���褦�ˡ����ƤӽФ����ORDER BY�����Ȥ������ǽ�Ȥʤ�ޤ����̤���ˡ�Ȥ��ơ��¤��ؤ���줿���䤤��碌���������ͤ뤹�뤳�ȤǤ��꤯�����ޤ�������ޤ���
SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
���������ι�ʸ��SQLɸ��Ǥϵ�����Ƥ��餺��¾�Υǡ����١��������ƥ�˰ܿ����Ϥ���ޤ���
���ײ��Ͻ����ˤ褯���Ѥ���뽸��ؿ���表9-43�˼����ޤ��� �ʤ����ϡ�������Ū�˻��Ѥ���뽸��ؿ��Ȥκ�����ɤ�������̽Ф����ޤ������� ��������ʬ�ˤ�����N�ϡ����٤Ƥ����ϼ�����NULL�����ϹԤθĿ���ɽ���ޤ��� ���٤Ƥξ��ˤơ��㤨��N��0�λ��ʤɷ���̵��̣�Ǥ�����ˤ�NULL���֤���ޤ���
表 9-43. �������Ѥν���ؿ�
�ؿ� | �����η� | ����ͤη� | ���� |
---|---|---|---|
corr(Y, X)
| double precision | double precision | ��ط��� |
covar_pop(Y, X)
| double precision | double precision | �춦ʬ�� |
covar_samp(Y, X)
| double precision | double precision | ɸ�ܶ�ʬ�� |
regr_avgx(Y, X)
| double precision | double precision | ��Ω�ѿ���ʿ���� (sum(X)/N) |
regr_avgy(Y, X)
| double precision | double precision | ��¸�ѿ���ʿ���� (sum(Y)/N) |
regr_count(Y, X)
| double precision | bigint | ξ������NULL�Ȥʤ����ϹԤθĿ� |
regr_intercept(Y, X)
| double precision | double precision | (X, Y)���Ȥ߹�碌�Ƿ�ޤ롢�������������Ф���Ǿ����ˡ��Y���� |
regr_r2(Y, X)
| double precision | double precision | ��ط��������� |
regr_slope(Y, X)
| double precision | double precision | X, Y)���Ȥ߹�碌�Ƿ�ޤ롢�Ǿ�����ˡ�˹礦�����������η��� |
regr_sxx(Y, X)
| double precision | double precision | sum(X^2) - sum(X)^2/N �ʰ�¸�ѿ���"�����"�� |
regr_sxy(Y, X)
| double precision | double precision | sum(X*Y) - sum(X) * sum(Y)/N �ʰ�¸�ѿ�����Ω�ѿ���"��"�� |
regr_syy(Y, X)
| double precision | double precision | sum(Y^2) - sum(Y)^2/N ����Ω�ѿ���"������"�� |
stddev(expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | stddev_samp �����Ū����̾ |
stddev_pop(expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | �����ͤ��Ф�����ɸ���к� |
stddev_samp(expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | �����ͤ��Ф���ɸ��ɸ���к� |
variance (expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | var_samp �����Ū����̾ |
var_pop (expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | �����ͤ��Ф�����ʬ������ɸ���к��μ���� |
var_samp (expression)
| smallint��int�� bigint��real��double precision���ޤ���numeric | ��ư���������ΰ����Ǥ�double precision������ʳ��Ǥ�numeric | �����ͤ��Ф���ɸ��ʬ����ɸ��ɸ���к������� |