select.sgml 22.2 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.24 2000/01/27 18:11:25 tgl Exp $
3 4 5
Postgres documentation
-->

6 7
<refentry id="SQL-SELECT">
 <refmeta>
8
  <refentrytitle id="sql-select-title">
9
   SELECT
10 11 12 13 14
  </refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
  <refname>
15
   SELECT
16 17 18 19 20 21
  </refname>
  <refpurpose>
   Retrieve rows from a table or view.
  </refpurpose></refnamediv>
 <refsynopsisdiv>
  <refsynopsisdivinfo>
22
   <date>1999-07-20</date>
23 24
  </refsynopsisdivinfo>
  <synopsis>
25
SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ]
26 27 28
    <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
    [ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
    [ FROM <replaceable class="PARAMETER">table</replaceable> [ <replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
29 30 31
    [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
    [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
    [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
32
    [ { UNION [ ALL ] | INTERSECT | EXCEPT } <replaceable class="PARAMETER">select</replaceable> ]
33
    [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
34 35
    [ FOR UPDATE [ OF class_name... ] ]
    [ LIMIT { count | ALL } [ { OFFSET | , } count ] ]
36 37 38 39
  </synopsis>
  
  <refsect2 id="R2-SQL-SELECT-1">
   <refsect2info>
40
    <date>1998-09-24</date>
41 42 43 44
   </refsect2info>
   <title>
    Inputs
   </title>
45

46 47 48
   <para>
    <variablelist>
     <varlistentry>
49
      <term><replaceable class="PARAMETER">expression</replaceable></term>
50 51 52 53 54 55 56 57
      <listitem>
       <para>
	The name of a table's column or an expression.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
58
      <term><replaceable class="PARAMETER">name</replaceable></term>
59 60 61 62 63 64 65 66 67 68 69
      <listitem>
       <para>
	Specifies another name for a column or an expression using
	the AS clause. <replaceable class="PARAMETER">name</replaceable>
	cannot be used in the WHERE
	condition. It can, however, be referenced in associated
	ORDER BY or GROUP BY clauses.
       </para>
      </listitem>
     </varlistentry>
     
T
Thomas G. Lockhart 已提交
70
    <varlistentry>
71 72
     <term>TEMPORARY</term>
     <term>TEMP</term>
T
Thomas G. Lockhart 已提交
73 74
     <listitem>
      <para>
75 76
	The table is created unique to this session, and is
	automatically dropped on session exit.
T
Thomas G. Lockhart 已提交
77 78 79
      </para>
     </listitem>
    </varlistentry>
80

81
     <varlistentry>
82
      <term><replaceable class="PARAMETER">new_table</replaceable></term>
83 84 85 86 87
      <listitem>
       <para>
	If the INTO TABLE clause is specified, the result of the
	query will be stored in another table with the indicated
	name.
T
Thomas G. Lockhart 已提交
88 89 90 91
	The target table (<replaceable class="PARAMETER">new_table</replaceable>) will
	be created automatically and should not exist before this command.
        Refer to <command>SELECT INTO</command> for more information.

92 93 94 95 96 97 98 99 100 101 102
	<note>
	 <para>
	  The <command>CREATE TABLE AS</command> statement will also
	  create a new  table from a select query.
	 </para>
	</note>
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
103
      <term><replaceable class="PARAMETER">table</replaceable></term>
104 105 106 107 108 109 110 111
      <listitem>
       <para>
	The name of an existing table referenced by the FROM clause.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
112
      <term><replaceable class="PARAMETER">alias</replaceable></term>
113 114 115 116 117 118 119 120 121 122 123
      <listitem>
       <para>
	An alternate name for the preceding
	<replaceable class="PARAMETER">table</replaceable>.
	It is used for brevity or to eliminate ambiguity for joins
	within a single table.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
124
      <term><replaceable class="PARAMETER">condition</replaceable></term>
125 126 127 128 129 130 131 132 133
      <listitem>
       <para>
	A boolean expression giving a result of true or false.
	See the WHERE clause.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
134
      <term><replaceable class="PARAMETER">column</replaceable></term>
135 136 137 138 139 140 141 142
      <listitem>
       <para>
	The name of a table's column.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
143
      <term><replaceable class="PARAMETER">select</replaceable></term>
144 145 146 147 148 149 150 151 152 153 154 155 156
      <listitem>
       <para>
	A select statement with all features except the ORDER BY clause.
       </para>
      </listitem>
     </varlistentry>
     
    </variablelist>
   </para>
  </refsect2>
  
  <refsect2 id="R2-SQL-SELECT-2">
   <refsect2info>
157
    <date>1998-09-24</date>
158 159 160 161
   </refsect2info>
   <title>
    Outputs
   </title>
162
   <para>
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184

    <variablelist>
     <varlistentry>
      <term>Rows</term>
      <listitem>
       <para>
	The complete set of rows resulting from the query specification.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>
       <returnvalue><replaceable>count</replaceable></returnvalue>
      </term>
      <listitem>
       <para>
	The count of rows returned by the query.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
185
   </para>
186 187
  </refsect2>
 </refsynopsisdiv>
188

189 190
 <refsect1 id="R1-SQL-SELECT-1">
  <refsect1info>
191
   <date>1998-09-24</date>
192 193 194 195 196
  </refsect1info>
  <title>
   Description
  </title>
  <para>
197 198
   <command>SELECT</command> will return rows from one or more tables.
   Candidates for selection are rows which satisfy the WHERE condition;
199
   if WHERE is omitted, all rows are candidates.
200
   (See <xref linkend="sql-where" endterm="sql-where-title">.)
201 202
  </para>

203
  <para>
204
   <command>DISTINCT</command> will eliminate duplicate rows from the
205
   result.
206
   <command>ALL</command> (the default) will return all candidate rows,
207 208
   including duplicates.
  </para>
209

210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
  <para>
   <command>DISTINCT ON</command> eliminates rows that match on all the
   specified expressions, keeping only the first row of each set of
   duplicates.  Note that "the first row" of each set is unpredictable
   unless <command>ORDER BY</command> is used to ensure that the desired
   row appears first.  For example,
   <programlisting>
        SELECT DISTINCT ON (location) location, time, report
        FROM weatherReports
        ORDER BY location, time DESC;
   </programlisting>
   retrieves the most recent weather report for each location.  But if
   we had not used ORDER BY to force descending order of time values
   for each location, we'd have gotten a report of unpredictable age
   for each location.
  </para>

227
  <para>
228
   The GROUP BY clause allows a user to divide a table
229
   conceptually into groups.
230
   (See <xref linkend="sql-groupby" endterm="sql-groupby-title">.)
231 232
  </para>

233
  <para>
234 235
   The HAVING clause specifies a grouped table derived by the
   elimination of groups from the result of the previously
236
   specified clause.
237
   (See <xref linkend="sql-having" endterm="sql-having-title">.)
238
  </para>
239 240
   
  <para>
241 242
   The ORDER BY clause allows a user to specify that he/she
   wishes the rows sorted according to the ASCending or 
243
   DESCending mode operator.
244
   (See <xref linkend="sql-orderby-title" endterm="sql-orderby-title">.)
245
  </para>
246 247
   
  <para>
248
   The UNION clause allows the result to be the collection of rows
249
   returned by the queries involved.
250
   (See <xref linkend="sql-union" endterm="sql-union-title">.)
251
  </para>
252 253 254
   
  <para>
   The INTERSECT give you the rows that are common to both queries.
255
   (See <xref linkend="sql-intersect" endterm="sql-intersect-title">.)
256
  </para>
257 258 259
   
  <para>
   The EXCEPT give you the rows in the upper query not in the lower query.
260
   (See <xref linkend="sql-except" endterm="sql-except-title">.)
261
  </para>
262
   
263 264 265
  <para>
   The FOR UPDATE clause allows the SELECT statement to perform 
   exclusive locking of selected rows.
266
  </para>
267 268
   
  <para>
269
   The LIMIT clause allows control over which rows are
270 271
   returned by the query.
  </para>
272

273
  <para>
274
   You must have SELECT privilege to a table to read its values
275 276
   (See the <command>GRANT</command>/<command>REVOKE</command> statements).
  </para>
277
   
278
  <refsect2 id="SQL-WHERE">
279
   <refsect2info>
280
    <date>1998-09-24</date>
281
   </refsect2info>
282
   <title id="sql-where-title">
283
    WHERE Clause
284
   </title>
285

286 287 288 289
   <para>
    The optional WHERE condition has the general form:
    
    <synopsis>
290
WHERE <replaceable class="PARAMETER">boolean_expr</replaceable>
291 292
    </synopsis>
    
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
    <replaceable class="PARAMETER">boolean_expr</replaceable>
    can consist of any expression which evaluates to a boolean value.
    In many cases, this expression will be

    <synopsis>
     <replaceable class="PARAMETER">expr</replaceable> <replaceable class="PARAMETER">cond_op</replaceable> <replaceable class="PARAMETER">expr</replaceable>
    </synopsis>

    or

    <synopsis>
     <replaceable class="PARAMETER">log_op</replaceable> <replaceable class="PARAMETER">expr</replaceable>
    </synopsis>

    where <replaceable class="PARAMETER">cond_op</replaceable>
    can be one of: =, &lt;, &lt;=, &gt;, &gt;= or &lt;&gt;,
    a conditional operator like ALL, ANY, IN, LIKE, or a
310
    locally-defined operator, 
311 312 313 314 315 316 317 318
    and <replaceable class="PARAMETER">log_op</replaceable> can be one 
    of: AND, OR, NOT.
    The comparison returns either TRUE or FALSE and all
    instances will be discarded
    if the expression evaluates to FALSE.
   </para>
  </refsect2>
  
319
  <refsect2 id="SQL-GROUPBY">
320
   <refsect2info>
321
    <date>1998-09-24</date>
322
   </refsect2info>
323
   <title id="sql-groupby-title">
324
    GROUP BY Clause
325 326
   </title>
   <para>
327
    GROUP BY specifies a grouped table derived by the application
328
    of this clause:
329
    <synopsis>
330
GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...]
331 332 333 334 335
    </synopsis>
   </para>

   <para>
    GROUP BY will condense into a single row all rows that share the
336 337 338 339 340 341 342
    same values for the grouped columns.  Aggregate functions, if any,
    are computed across all rows making up each group, producing a
    separate value for each group (whereas without GROUP BY, an
    aggregate produces a single value computed across all the selected
    rows).  When GROUP BY is present, it is not valid to refer to
    ungrouped columns except within aggregate functions, since there
    would be more than one possible value to return for an ungrouped column.
343 344 345
   </para>
  </refsect2>

346
  <refsect2 id="SQL-HAVING">
347
   <refsect2info>
348
    <date>1998-09-24</date>
349
   </refsect2info>
350
   <title id="sql-having-title">
351
    HAVING Clause
352 353 354 355 356 357 358 359 360
   </title>
   <para>
    The optional HAVING condition has the general form:
    
    <synopsis>
HAVING <replaceable class="PARAMETER">cond_expr</replaceable>
    </synopsis>
    
    where <replaceable class="PARAMETER">cond_expr</replaceable> is the same
361 362
    as specified for the WHERE clause.
   </para>
363 364
    
   <para>
365 366
    HAVING specifies a grouped table derived by the elimination
    of groups from the result of the previously specified clause
367
    that do not meet the <replaceable class="PARAMETER">cond_expr</replaceable>.</para>
368

369
   <para>
370
    Each column referenced in 
371
    <replaceable class="PARAMETER">cond_expr</replaceable> shall unambiguously
372 373
    reference a grouping column, unless the reference appears within an
    aggregate function.
374 375 376
   </para>
  </refsect2>
  
377
  <refsect2 id="SQL-ORDERBY">
378
   <refsect2info>
379
    <date>1998-09-24</date>
380
   </refsect2info>
381
   <title id="sql-orderby-title">
382
    ORDER BY Clause
383 384 385
   </title>
   <para>
    <synopsis>
386
ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...]
387 388 389 390
    </synopsis></para>
    
   <para>
    <replaceable class="PARAMETER">column</replaceable> can be either a column
391 392
    name or an ordinal number.
   </para>
393
   <para>
394 395 396
    The ordinal numbers refers to the ordinal (left-to-right) position
    of the column. This feature makes it possible to define an ordering
    on the basis of a column that does not have a proper name.
397 398
    This is never absolutely necessary because it is always possible
    assign a name
399
    to a calculated column using the AS clause, e.g.:
400
    <programlisting>
401
SELECT title, date_prod + 1 AS newlen FROM films ORDER BY newlen;
402 403 404
    </programlisting></para>
    
   <para>
405 406
    From release 6.4 of PostgreSQL, the columns in the ORDER BY clause
    do not need to appear in the SELECT clause.
407
    Thus the following statement is now legal:
408
    <programlisting>
409
SELECT name FROM distributors ORDER BY code;
410 411
    </programlisting>
   </para>
412 413
    
   <para>
414 415
    Optionally one may add the keyword DESC (descending)
    or ASC (ascending) after each column name in the ORDER BY clause.
416 417
    If not specified, ASC is assumed by default.
   </para>
418 419
  </refsect2>
  
420
  <refsect2 id="SQL-UNION">
421
   <refsect2info>
422
    <date>1998-09-24</date>
423
   </refsect2info>
424
   <title id="sql-union-title">
425
    UNION Clause
426 427 428
   </title>
   <para>
    <synopsis>
429 430
<replaceable class="PARAMETER">table_query</replaceable> UNION [ ALL ] <replaceable class="PARAMETER">table_query</replaceable>
    [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
431
    </synopsis>
432

433 434
    where
    <replaceable class="PARAMETER">table_query</replaceable>
435 436
    specifies any select expression without an ORDER BY clause.
   </para>
437 438
    
   <para>
439 440
    The UNION clause allows the result to be the collection of rows
    returned by the queries involved. (See UNION clause).
441 442
    The two tables that represent the direct operands of the UNION must
    have the same number of columns, and corresponding columns must be
443 444
    of compatible data types.
   </para>
445 446 447
    
   <para>
    By default, the result of UNION does not contain any duplicate rows
448 449
    unless the ALL clause is specified.
   </para>
450 451
    
   <para>
452
    Multiple UNION operators in the same SELECT statement are
453
    evaluated left to right.
454
    Note that the ALL keyword is not global in nature, being 
455 456 457
    applied only for the current pair of table results.
   </para>

458 459
  </refsect2>

460
  <refsect2 id="SQL-INTERSECT">
461 462 463
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
464
   <title id="sql-intersect-title">
465 466 467 468
    INTERSECT Clause
   </title>
   <para>
    <synopsis>
469 470
<replaceable class="PARAMETER">table_query</replaceable> INTERSECT <replaceable class="PARAMETER">table_query</replaceable>
    [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
471 472 473 474
    </synopsis>
    
    where
    <replaceable class="PARAMETER">table_query</replaceable>
475 476 477
    specifies any select expression without an ORDER BY clause.
   </para>

478 479
   <para>
    The INTERSECT clause allows the result to be all rows that are 
480
    common to the involved queries.
481 482
    The two tables that represent the direct operands of the INTERSECT must
    have the same number of columns, and corresponding columns must be
483 484
    of compatible data types.
   </para>
485 486 487 488
    
   <para>
    Multiple INTERSECT operators in the same SELECT statement are
    evaluated left to right.
489
   </para>
490 491
  </refsect2>

492
  <refsect2 id="SQL-EXCEPT">
493 494 495
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
496
   <title id="sql-except-title">
497 498 499 500
    EXCEPT Clause
   </title>
   <para>
    <synopsis>
501
<replaceable class="PARAMETER">table_query</replaceable> EXCEPT <replaceable class="PARAMETER">table_query</replaceable>
502 503
     [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
    </synopsis>
504
    
505 506
    where
    <replaceable class="PARAMETER">table_query</replaceable>
507 508 509
    specifies any select expression without an ORDER BY clause.
   </para>

510 511 512 513 514
   <para>
    The EXCEPT clause allows the result to be rows from the upper query
    that are not in the lower query.  (See EXCEPT clause).
    The two tables that represent the direct operands of the EXCEPT must
    have the same number of columns, and corresponding columns must be
515 516 517
    of compatible data types.
   </para>

518 519 520
   <para>
    Multiple EXCEPT operators in the same SELECT statement are
    evaluated left to right.
521
   </para>
522
  </refsect2>
523
 </refsect1>
524

525 526 527 528
 <refsect1 id="R1-SQL-SELECT-2">
  <title>
   Usage
  </title>
529

530 531 532
  <para>
   To join the table <literal>films</literal> with the table
   <literal>distributors</literal>:
533 534

   <programlisting>
535 536 537
SELECT f.title, f.did, d.name, f.date_prod, f.kind
    FROM distributors d, films f
    WHERE f.did = d.did
538

T
Thomas G. Lockhart 已提交
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
title                    |did|name            | date_prod|kind
-------------------------+---+----------------+----------+----------
The Third Man            |101|British Lion    |1949-12-23|Drama
The African Queen        |101|British Lion    |1951-08-11|Romantic
Une Femme est une Femme  |102|Jean Luc Godard |1961-03-12|Romantic
Vertigo                  |103|Paramount       |1958-11-14|Action
Becket                   |103|Paramount       |1964-02-03|Drama
48 Hrs                   |103|Paramount       |1982-10-22|Action
War and Peace            |104|Mosfilm         |1967-02-12|Drama
West Side Story          |105|United Artists  |1961-01-03|Musical
Bananas                  |105|United Artists  |1971-07-13|Comedy
Yojimbo                  |106|Toho            |1961-06-16|Drama
There's a Girl in my Soup|107|Columbia        |1970-06-11|Comedy
Taxi Driver              |107|Columbia        |1975-05-15|Action
Absence of Malice        |107|Columbia        |1981-11-15|Action
Storia di una donna      |108|Westward        |1970-08-15|Romantic
The King and I           |109|20th Century Fox|1956-08-11|Musical
Das Boot                 |110|Bavaria Atelier |1981-11-11|Drama
Bed Knobs and Broomsticks|111|Walt Disney     |          |Musical
558 559 560
   </programlisting>
  </para>

561 562
  <para>
   To sum the column <literal>len</literal> of all films and group
563
   the results by <literal>kind</literal>:
564 565

   <programlisting>
566
SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
567 568 569 570 571 572 573 574

    kind      |total
    ----------+------
    Action    | 07:34
    Comedy    | 02:58
    Drama     | 14:28
    Musical   | 06:42
    Romantic  | 04:38
575 576
   </programlisting>
  </para>
577 578 579

  <para>
   To sum the column <literal>len</literal> of all films, group
580
   the results by <literal>kind</literal> and show those group totals
581
   that are less than 5 hours:
582 583

   <programlisting>
584 585 586 587
SELECT kind, SUM(len) AS total
    FROM films
    GROUP BY kind
    HAVING SUM(len) < INTERVAL '5 hour';
588 589 590 591 592

    kind      |total
    ----------+------
    Comedy    | 02:58
    Romantic  | 04:38
593 594 595
   </programlisting>
  </para>

596
  <para>
597
   The following two examples are identical ways of sorting the individual
598 599
   results according to the contents of the second column
   (<literal>name</literal>):
600 601

   <programlisting>
602 603
SELECT * FROM distributors ORDER BY name;
SELECT * FROM distributors ORDER BY 2;
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619

    did|name
    ---+----------------
    109|20th Century Fox
    110|Bavaria Atelier
    101|British Lion
    107|Columbia
    102|Jean Luc Godard
    113|Luso films
    104|Mosfilm
    103|Paramount
    106|Toho
    105|United Artists
    111|Walt Disney
    112|Warner Bros.
    108|Westward
620 621
   </programlisting>
  </para>
622 623 624 625 626 627 628

  <para>
   This example shows how to obtain the union of the tables
   <literal>distributors</literal> and
   <literal>actors</literal>, restricting the results to those that begin
   with letter W in each table.  Only distinct rows are to be used, so the
   ALL keyword is omitted:
629 630

   <programlisting>
631
    --        distributors:                actors:
632 633 634 635 636 637
    --        did|name                     id|name
    --        ---+------------             --+--------------
    --        108|Westward                  1|Woody Allen
    --        111|Walt Disney               2|Warren Beatty
    --        112|Warner Bros.              3|Walter Matthau
    --        ...                           ...
638

639
SELECT distributors.name
640 641
    FROM   distributors
    WHERE  distributors.name LIKE 'W%'
642 643 644 645
UNION
SELECT actors.name
    FROM   actors
    WHERE  actors.name LIKE 'W%'
646

T
Thomas G. Lockhart 已提交
647 648 649 650 651 652 653 654
name
--------------
Walt Disney
Walter Matthau
Warner Bros.
Warren Beatty
Westward
Woody Allen
655 656
   </programlisting>
  </para>
657 658 659 660 661 662 663 664
 </refsect1>
 
 <refsect1 id="R1-SQL-SELECT-3">
  <title>
   Compatibility
  </title>
  
  <refsect2 id="R2-SQL-SELECT-4">
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
    <acronym>Extensions</acronym>
   </title>

   <para>
<productname>Postgres</productname> allows one to omit 
the <command>FROM</command> clause from a query. This feature
was retained from the original PostQuel query language:
  <programlisting>
SELECT distributors.* WHERE name = 'Westwood';

    did|name
    ---+----------------
    108|Westward
  </programlisting>
   </para>
684
  </refsect2>
685 686

  <refsect2 id="R2-SQL-SELECT-5">
687
   <refsect2info>
688
    <date>1998-09-24</date>
689 690 691 692 693 694 695 696 697 698 699 700
   </refsect2info>
   <title>
    <acronym>SQL92</acronym>
   </title>
   <para>
   </para>
   
   <refsect3 id="R3-SQL-SELECT-1">
    <refsect3info>
     <date>1998-04-15</date>
    </refsect3info>
    <title>
701
     SELECT Clause
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
    </title>
    <para>
     In the <acronym>SQL92</acronym> standard, the optional keyword "AS"
     is just noise and can be 
     omitted without affecting the meaning.
     The <productname>Postgres</productname> parser requires this keyword when
     renaming columns because the type extensibility features lead to
     parsing ambiguities
     in this context.</para>
     
    <para>
     In the <acronym>SQL92</acronym> standard, the new column name 
     specified in an
     "AS" clause may be referenced in GROUP BY and HAVING clauses.
     This is not currently
     allowed in <productname>Postgres</productname>.
    </para>
719 720 721 722
     
    <para>
     The DISTINCT ON phrase is not part of <acronym>SQL92</acronym>.
    </para>
723 724 725 726
   </refsect3>

   <refsect3 id="R3-SQL-UNION-1">
    <refsect3info>
727
     <date>1998-09-24</date>
728 729
    </refsect3info>
    <title>
730
     UNION Clause
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
    </title>
    <para>
     The <acronym>SQL92</acronym> syntax for UNION allows an
     additional CORRESPONDING BY clause:
     <synopsis> 
<replaceable class="PARAMETER">table_query</replaceable> UNION [ALL]
    [CORRESPONDING [BY (<replaceable class="PARAMETER">column</replaceable> [,...])]]
    <replaceable class="PARAMETER">table_query</replaceable>
     </synopsis></para>

    <para>
     The CORRESPONDING BY clause is not supported by
     <productname>Postgres</productname>.
    </para>
   </refsect3>
   
  </refsect2>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
754
sgml-omittag:nil
755 756 757 758 759 760 761 762 763 764 765
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
766
-->