select (minimum)

Retrieves rows from database objects.

Syntax

Transact-SQL Syntax

select [all | distinct] select_list
 [into [[database.]owner.]table_name]
 [from [[database.]owner.]{view_name | table_name
[(index index_name [prefetch size][lru | mru])]}
 [holdlock | noholdlock] [shared]
 [,[[database.]owner.]{view_name | table_name
[(index index_name [prefetch size][lru | mru])]}
 [holdlock | noholdlock] [shared]]...]
[where search_conditions]
[group by [all]aggregate_free_expression
[, aggregate_free_expression]...]
 [having search_conditions]
[order by
 {[[[database.]owner.]{table_name. | view_name.}]
 column_name | select_list_number | expression}
 [asc | desc]
 [,{[[[database.]owner.]{table_name. | view_name.}]
 column_name | select_list_number | expression}
 [asc | desc]]...]
[compute row_aggregate(column_name)
 [, row_aggregate(column_name)]...
 [by column_name [, column_name]...]]
[for {{read only | update [of column_name_list]}]
[at isolation {read uncommitted | read committed | serializable}]
[for browse]

ODBC Syntax

SELECT [ALL|DISTINCT]select_list
FROM table_reference_list
[WHERE search_condition]
[GROUP BY column_name[,column_name]...]
[HAVING search_condition]
[UNION [ALL]select_statement]...
 [order_by_clause]
An alternate syntax for updating tables if the driver supports core or extended functionality:
SELECT [ALL|DISTINCT]select_list
FROM table_reference_list
[WHERE search_condition]
FOR UPDATE OF [column_name[,column_name]...]

Parameters

Examples

Usage

  • You can issue this command as a language command or a client-based cursor request.

  • This statement is accepted and sent to ODBC without change, subject to the qualifications listed in this section.

  • The TEXTPTR() function cannot appear in the select list.

  • These Microsoft SQL Server 10.x aggregate functions are supported:
    • sum ( [all | distinct] )

    • avg ( [all | distinct] )

    • count ( [all | distinct] )

    • count (*)

    • max (expression))

    • min (expression))

  • If the command is issued as a cursor, the access service library supports these cursor commands:
    • declare

    • open

    • fetch

    • close

    • deallocate

  • If a cursor is passed a new set of parameters before it is opened, it can be reused multiple times.

  • The data values used in the where clause search conditions are passed as cursor parameters, using the datatype associated with the column.

  • Cursor parameters are indicated with the “@” character when Transact-SQL syntax is used, and with a question mark when passthrough mode is used.

  • These are not supported:
    • Transact-SQL select into syntax

    • The use of index in a from clause

    • The use of prefetch size in a from clause

    • The use of holdlock|noholdlock|shared in a from clause

    • The compute phrase

    • The at isolation phrase

    • The for browse phrase

  • The availability of the GROUP BY, HAVING, and UNION clauses depends upon the ODBC driver level of conformance.