|
The features on this page require a GENESIS64 Advanced license and are not available with GENESIS64 Basic SCADA . |
The FROM keyword is generally required in AnalytiX-BI queries, unless the query is selecting only constants.
Tables specified with the FROM keyword can be aliased for self-joining purposes or just to simplify the query. The following example shows how to retrieve columns from a couple of joined tables using aliases.
SELECT c.CategoryName, p.ProductName
FROM Categories AS c INNER JOIN Products AS p
ON c.CategoryID = p.CategoryID
Note: the AS keyword is required in AnalytiX-BI when aliasing tables.
The argument to the FROM keyword can be either a table, a view, a parameterized view or a subquery. The following example shows how to retrieve data from a parameterized view that returns orders given a customer ID.
SELECT * FROM OrdersByCustomerID('ALFKI')
The following example shows how to use a subquery in the FROM clause. Note that the subquery requires an alias using the AS keyword in order to qualify the columns projected by the subquery.
SELECT t.CustomerID, t.OrderID
FROM
(SELECT c.CustomerID, o.OrderID, o.OrderDate
FROM Customers AS c INNER JOIN Orders AS o
ON c.CustomerID = o.CustomerID
WHERE o.OrderDate > '1/1/1997') AS t
ORDER BY t.OrderDate
AnalytiX-BI allows omitting the FROM keyword and the table(s) involved in the query are automatically determined from the list of requested attributes. When omitting the FROM keyword it is required that all attributes used in the query are fully qualified with their table name, as shown in the following example.
SELECT Categories.CategoryID, Categories.CategoryName
Note: although this syntax is supported for backwards compatibility, it is recommended to always specify the table(s) involved in the query using the FROM keyword.