Show TOC

Syntax documentationQuery Specification Locate this document in the navigation structure

The query specification represents the result of a complex database query. The most common SELECT statements are just query specifications.

Syntax Syntax

  1. <query specification> ::= 
        SELECT ( DISTINCT | ALL )? 
            <select list> <from clause> 
              ( <where clause> )? ( <group by clause> )?
                ( <having clause> )?.
    
End of the code.

The result of a <query specification> is constructed as follows:

  1. The <from clause>is evaluated.

  2. If a <where clause> is specified, the result is filtered by applying the <search condition> of the <where clause>. The new result has the same degree as the previous result.

  3. If a <group by clause> is specified, the specified grouping is performed on the result. The new result has the same degree as the previous result.

  4. If a <having clause> is specified, the result is filtered by applying the <search condition> of the <having clause>. The new result has the same degree as the previous result.

  5. The <value expression>s in the <select list> is calculated. The new result is a table that has the degree and the <display name>s of the <select list>.

  6. If DISTINCT is specified, all duplicate rows from the result are filtered. Else the result remains unchanged. (Specifying ALL has no effect.)

DISTINCT may be specified only once in a <query specification>.