Derived Tables with Firebird 2.0

26 04 2005 Computers & IT
The Firebird Developer-Team is working intensley on the next major release 2.0 of its relational database server. On the 21th of March 2005 Firebird 2.0 Alpha-01 was released for all those people who are curious about this one and are able to download and test the latest build.

One new feature is the support of Derived Tables.

A derived table is one that is created on-the-fly using the SELECT statement, and referenced just like a regular table or view. Derived tables exist in memory and can only be referenced by the outer SELECT in which they are created. A simple use of a derived table is shown here.

SELECT 
FROM (SELECT

FROM Sales) AS a

The inner SELECT produces a derived table and replaces a regular table or view. The key thing to remember when using derived tables is that you must always use an alias (e.g., AS a). The following shows the error produced when the alias is omitted.

SELECT 
FROM (SELECT

FROM Sales)