Here are basic rules you need to create a view. I have shared already what is read only view and updatable view.
View is a logical table. On top of base table yoy can create it. Here are three rules.
No ORDER BY inside the View CREATE
All Aggregation needs to have an ALIAS
Any Derived columns (such as Math) needs an ALIAS
Here’s Sample SQL to create View
CREATE View Department_Salaries AS
SELECT Dept_No
,SUM(Salary) as SumSal
,SUM(Salary) / 12 as MonthSal
FROM Employee_Table
GROUP BY 1;The above is the query to create a view. You can read one more example to create a view.
However, the SQL below is to retrieve data from SQL query
SEL * FROM Department_Salaries Order By 1 ;
Dept_No SumSal MonthSal
________ ________ __________
? 32800.50 2733.38
10 64300.00 5358.33
100 48850.00 4070.83
200 89888.88 7490.74
300 40200.00 3350.00
400 145000.00 12083.33Also read how Salesforce is using AI without SQL for your quick reference.
