SELECT in Greenplum

Select statement is used to select data from a table or view. In Greenplum you can do much more in SELECT statement than simple select.  

SELECT [ALL | DISTINCT [ON (expression [, ...])]]

 * | expression [[AS] output_name] [, ...]

 [FROM from_item [, ...]]

 [WHERE condition]

 [GROUP BY grouping_element [, ...]]

 [HAVING condition [, ...]]

 [WINDOW window_name AS (window_specification)]

 [{UNION | INTERSECT | EXCEPT} [ALL] select]

 [ORDER BY expression [ASC | DESC | USING operator] [, ...]]

 [LIMIT {count | ALL}]

 [OFFSET start]

 [FOR {UPDATE | SHARE} [OF table_name [, ...]] [NOWAIT] [...]]

where grouping_element can be one of:

 ()

expression

 ROLLUP (expression [,...])

 CUBE (expression [,...])

 GROUPING SETS ((grouping_element [, ...]))

where window_specification can be:

[window_name]

 [PARTITION BY expression [, ...]]

 [ORDER BY expression [ASC | DESC | USING operator] [, ...]

 [{RANGE | ROWS}

 { UNBOUNDED PRECEDING

 | expression PRECEDING

 | CURRENT ROW

 | BETWEEN window_frame_bound AND window_frame_bound }]]

where window_frame_bound can be one of:

 UNBOUNDED PRECEDING

expression PRECEDING

 CURRENT ROW

expression FOLLOWING

 UNBOUNDED FOLLOWING

where from_item can be one of:

[ONLY] table_name [[AS] alias [( column_alias [, ...] )]]

(select) [AS] alias [( column_alias [, ...] )]

function_name ( [argument [, ...]] ) [AS] alias

 [( column_alias [, ...]

 | column_definition [, ...] )]

function_name ( [argument [, ...]] ) AS

 ( column_definition [, ...] )

from_item [NATURAL] join_type from_item

 [ON join_condition | USING ( join_column [, ...] )]