Declarative Objectivity (DO) Language : Data Statements : RETURN Statement
RETURN Statement
A RETURN statement returns a sequence of objects or projections selected from the source of the query.
  
Syntax 
returnStatement
 : fromClause whereClause? groupByClause? orderByClause? skip? take? returnClause;
   |
   returnClause fromClause whereClause? groupByClause? orderByClause? skip? take?;
skip : skipClause | skipWhileClause;
take : takeClause | takeWhileClause;
Quick Look 
Return all vehicles that haven’t been retired:
FROM Vehicles WHERE retired == false RETURN *;
Get the licenses of all vehicles that haven’t been retired:
FROM Vehicles WHERE retired == false RETURN license;
Get the licenses and availability of the vehicles that haven’t been retired:
FROM Vehicles WHERE retired == false RETURN license, available;
Same as preceding, using alternative syntax:
RETURN license, available FROM Vehicles WHERE retired == false;
Get the postal code of a particular rental company—returns an attribute value from an embedded object:
FROM RentalCompany WHERE name == 'Acme Auto' RETURN corporateAddress.postalCode;
Get the licenses and availability of a rental company’s vehicles—returns values from a collection of referenced objects:
FROM RentalCompany WHERE name == 'Acme Auto' RETURN vehicles.license, vehicles.available;
Return the reservations that are less than a day old:
FROM Reservation WHERE ($$NOW - timestamp) < INTERVAL{days:1} return *;
Discussion 
A RETURN statement returns values that are selected or derived from the source of the query. The query source is designated by the FROM Clause and consists of the sequence of objects that instantiate the specified schema class. The objects in the query source may be filtered by an optional WHERE Clause, which qualifies or disqualifies each object based on the values of direct or indirect attributes. A qualified source object is retained in the sequence, and disqualified objects are filtered out.
The resulting (possibly filtered) sequence of objects is passed to the RETURN Clause, which specifies whether to return whole objects, or projections consisting of particular values extracted or derived from the objects.
For example, the query source in the following statement consists of all Vehicle objects currently stored in the data store. Each Vehicle is considered a qualified source object if its retired attribute has the value false. The statement returns a projection from each qualified source object, consisting of the values of the license and available attributes:
FROM Vehicles WHERE retired == false RETURN license, available;
In traditional database terminology, the WHERE clause is the selection operator (identifying a subset of the objects to query) and the RETURN clause is the projection operator (determining which values to return). For further discussion, see Projection Operator.
Optional Clauses
A RETURN statement can include the following optional clauses:
GROUP BY Clause—organizes source objects into temporary groups according to specified criteria, typically for use with aggregate operators.
ORDER BY Clause—sorts a query’s results according to one or more values that can be accessed from the source objects.
SKIP Clause or SKIP WHILE Clause—controls the portion of the query's results to return.
TAKE Clause or TAKE WHILE Clause—also controls the portion of the query's results to return.
Alternative Syntax
The RETURN clause can be the leading or trailing clause in the RETURN statement. In addition, the keyword SELECT can be substituted for RETURN. Hence these four statements are equivalent:
FROM Vehicles RETURN * ;
FROM Vehicles SELECT * ;
RETURN * FROM Vehicles ;
SELECT * FROM Vehicles ;