Accessing a Collection Through a Virtual Table
When you use the collection expression format of the collection-derived table segment to access the elements of a collection, you can select elements of the collection directly through a virtual table. You can use this format in the FROM clause of a SELECT statement. The FROM clause can be in either a query or a subquery.
With this format you can use joins, aggregates, the WHERE clause, expressions, the ORDER BY clause, and other operations that are not available when you use the collection-variable format. This format reduces the need for multiple cursors and temporary tables.
Examples of possible collection expressions include column references, scalar subquery, dotted expression, functions, operators (through overloading), collection subqueries, literal collections, collection constructors, cast functions, and so on.
SELECT * FROM TABLE(MULTISET(SELECT SKIP 50 FIRST 20 * FROM employees ORDER BY employee_id)) vt(x,y), tab2 WHERE tab2.id = vt.x;
SELECT emp_id, emp_name, emp_salary FROM TABLE(MULTISET(SELECT SKIP 40 LIMIT 20 id, name, salary FROM e1, e2 WHERE e1.id = e2.id ORDER BY salary )) AS etab(emp_id, emp_name, emp_salary);