There are certain restrictions, both on the SELECT statements you use to create views, and on your ability to insert into, delete from, or update them.
You cannot use an ORDER BY clause in the SELECT query. A characteristic of relational tables is that there is no significance to the ordering of the rows or columns, and using an ORDER BY clause imposes an order on the rows of the view. You can use the GROUP BY clause, subqueries, and joins in view definitions.
Scalar value subqueries are supported only within the top-level SELECT list (not in a view, a derived table, or a subquery). Sometimes views or derived tables used in the FROM clause of the top level SELECT are simple enough that they can be “flattened” up into the top level SELECT. As a result of this, the preceding rule is actually enforced only for subqueries, nonflattened views, and nonflattened derived tables. For example:
SELECT * FROM test_view Msg 21, Level 14, State 0: SQL Anywhere Error -1005004: Subqueries are allowed only as arguments of comparisons, IN, and EXISTS, -- (opt_Select.cxx 2101)
To develop a view, tune the SELECT query by itself until it provides exactly the results you need in the format you want. Once you have the correct SELECT query, you can add a phrase in front of the query to create the view. For example:
CREATE VIEW viewname AS
UPDATE, INSERT, and DELETE statements are allowed on some views, but not on others, depending on their associated SELECT statement.
Aggregate functions, such as COUNT(*)
A GROUP BY clause in the SELECT statement
A UNION operation