View a markdown version of this page

FROM-first syntax - Amazon Athena

FROM-first syntax

You can start a query with the FROM clause and put the SELECT list after it. The other clauses follow in their usual order. If you leave out the SELECT list, the query returns every column, as with SELECT *.

A FROM-first query can also appear as a subquery.

Syntax

FROM from_item [, ...] [ SELECT select_list ] [ WHERE condition ] [ GROUP BY grouping_element [, ...] ] [ ORDER BY expression [, ...] ] [ LIMIT count ]

Examples

For a description of the sample tables that the examples on this page use, see SELECT statement in DuckDB.

The following SQL query puts FROM first and the select list second.

FROM sales_db.sales_parquet SELECT customer, amount WHERE region = 'west' ORDER BY customer

The query returns the following results.

customer amount

bob

75.00

erin

18.75

The following SQL query leaves out the select list, so it returns every column of the Iceberg table.

FROM sales_db.orders_iceberg ORDER BY order_id

The query returns the following results.

order_id customer region amount order_date

1

alice

east

120.50

2026-10-01

2

bob

west

75.00

2026-10-01

3

carol

east

42.25

2026-10-02

The following SQL query uses a FROM-first query without a select list as a subquery.

SELECT count(*) AS east_orders FROM (FROM sales_db.sales_parquet WHERE region = 'east')

The query returns the following result.

east_orders

3