21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Notes:<br />

DML statements<br />

select dbinfo.descr,<br />

dbinfo.def_charset<br />

from (select * from rdb$database) dbinfo<br />

(descr, rel_id, sec_class, def_charset)<br />

• Derived tables can be nested.<br />

• Derived tables can be unions and can be used in unions. They can contain aggregate functions, subselects and<br />

joins, and can themselves be used in aggregate functions, subselects and joins. They can also be or contain<br />

queries on selectable stored procedures. They can have WHERE, ORDER BY and GROUP BY clauses, FIRST,<br />

SKIP or ROWS directives, etc. etc.<br />

• Every column in a derived table must have a name. If it doesn't have one by nature (e.g. because it's a constant)<br />

it must either be given an alias in the usual way, or a column aliases list must be added to the derived table<br />

specification.<br />

• The column aliases list is optional, but if it is used it must be complete. That is: it must contain an alias for<br />

every column in the derived table.<br />

• The optimizer can handle a derived table very efficiently. However, if the derived table is involved in an<br />

inner join and contains a subquery, then no join order can be made.<br />

FIRST and SKIP<br />

Available in: DSQL, PSQL<br />

Added in: 1.0<br />

Changed in: 1.5<br />

Better alternative: ROWS<br />

Description: FIRST limits the output of a query to the first so-many rows. SKIP will suppress the given number<br />

of rows before starting to return output.<br />

Syntax:<br />

Tip<br />

In <strong>Firebird</strong> 2.0 and up, use the SQL-compliant ROWS syntax instead.<br />

SELECT [FIRST ()] [SKIP ()] FROM ...<br />

::= Any expression evaluating to an integer.<br />

::= The usual output column specifications.<br />

Note<br />

If is an integer literal or a query parameter, the “()” may be omitted. Subselects on<br />

the other hand require an extra pair of parentheses.<br />

72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!