SELECT clause

SELECT clause

select-clause:

SELECT ( [ALL | DISTINCT]  ( result-expression [, result-expression]*) | 
    (RAW | ELEMENT) expression) 

result-expression:

[(path .)] * | expression [ ([AS] alias) ]

path:

identifier [ [ expression ] ] [. path]

alias:

identifier

ALL

SELECT ALL retrieves all of the data specified. ALL will display "all" of the specified columns including all of the duplicates. The ALL keyword is the default if nothing is specified.

DISTINCT

The DISTINCT clause removes duplicate result objects from the query's result set. If the DISTINCT clause is not used, the query returns all objects that meet the query conditions in a result set, which might include duplicates.

Example

SELECT DISTINCT orderlines[0].productId FROM orders    

Results

{
  "results": [
    {
      "productId": "coffee01"
    },
    {
      "productId": "tea111"
    }
  ]
}  

If the query had run with no DISTINCT clause against orders with this SELECT statement, the result set would have been as follows:

SELECT  orderlines[0].productId
      FROM orders

Returns

 {
  "results": [
    {
      "productId": "coffee01"
    },
    {
      "productId": "coffee01"
    },
    {
      "productId": "tea111"
    },
    {
      "productId": "coffee01"
    }
  ]
}
Note: Starting version 4.5.1, the DISTINCT clause is no longer blocking in nature. It streams the input and produces the output in-parallel, all while consuming less memory.

RAW/ELEMENT

Specifies a raw expression.