CREATE VIEW
You can run a CREATE VIEW statement to begin using Compass views.
Syntax:
CREATE VIEW view_name AS select_statement
Example 1:
CREATE VIEW example_view_name AS (SELECT productname, companyname FROM orderDetailsObject)
Example 2:
CREATE VIEW sophisticatedExampleView as (
SELECT o.orderdate,
c.country,
ca.categoryname,
p.productname,
p.categoryid,
o.customerid,
c.companyname,
od.productid,
sum(od.quantity) AS quantity,
sum(od.quantity*od.unitprice) AS sales
FROM nw_orderdetails od
INNER JOIN nw_orders o
ON od.orderid=o.orderid
INNER JOIN nw_customers c
ON o.customerid=c.customerid
INNER JOIN nw_products p
ON od.productid=p.productid
INNER JOIN nw_categories ca
ON p.categoryid=ca.categoryid
GROUP BY o.orderdate,c.country, o.customerid, c.companyname, od.productid, p.productname, p.categoryid, ca.categoryname
ORDER BY o.customerid, ca.categoryname,p.productname ASC )