Just as the error says, the CREATE VIEW
statement needs to be the only statement in the query batch.
You have two option in this scenario, depending on the functionality you want to achieve:
- Place the
CREATE VIEW
query at the beginningCREATE VIEW showing as select tradename, unitprice, GenericFlag from Medicine; with ExpAndCheapMedicine(MostMoney, MinMoney) as ( select max(unitprice), min(unitprice) from Medicine ) , findmostexpensive(nameOfExpensive) as ( select tradename from Medicine, ExpAndCheapMedicine where UnitPrice = MostMoney ) , findCheapest(nameOfCheapest) as ( select tradename from Medicine, ExpAndCheapMedicine where UnitPrice = MinMoney )
- Use
GO
after the CTE and before theCREATE VIEW
query— Option #2
with ExpAndCheapMedicine(MostMoney, MinMoney) as ( select max(unitprice), min(unitprice) from Medicine ) , findmostexpensive(nameOfExpensive) as ( select tradename from Medicine, ExpAndCheapMedicine where UnitPrice = MostMoney ) , findCheapest(nameOfCheapest) as ( select tradename from Medicine, ExpAndCheapMedicine where UnitPrice = MinMoney ) GO CREATE VIEW showing as select tradename, unitprice, GenericFlag from Medicine;
Create View needs to add Go up and down, if there are other SQL up and down
Read More:
- [Solved] SAP MDG Create View Error: unexpected error while activating search view ZMDG_XXX
- [Solved] RuntimeError: each element in list of batch should be of equal size
- Win10 remote connection submits error by using cluster: Batch: error: batch script contains DOS line breaks (\R\n) sbatch: error
- [Solved] ArcGIS Error: Failed to create the site. One or more server machines could not be stopped
- How to Solve webpack -v View Error in vsode
- Hive Statement Error During Execution: Error while processing statement: FAILED: Execution Error, return code 2 from o
- [Solved] spring boot – JPA–H2 Error: H2 error: “Syntax error in SQL statement … expected identifier“
- [Solved] MindSpore Error: “RuntimeError: Unexpected error. Inconsistent batch..
- ORA-24338 statement handle not executed [How to Solve]
- The showdialog() method in thread/threading. Timer/task reported an error: “before ole can be called, the current thread must be set to single thread unit (STA) mode.”
- Chart.js Error: “Canvas is already in use. Chart …must be destroyed before the canvas can be reused”
- [Solved] Service Start Error When Horizon View Composer is Installing
- PIP Fatal error in launcher: Unable to create process using
- [Fixed]ERROR: canceling statement due to conflict with recovery
- [Solved] Doris StreamLoad Error: load by MERGE or DELETE need to upgrade table to support batch delete
- Error starting vue project these dependencies were not found:create in ./src/router/modules/md.js
- Docker: How to Enter the Closed Container and View the Logging
- Template cannot be rendered due to the joint query of populate in mongoose: syntax error: unexpected token r in JSON at position 0
- Uncaught SyntaxError: Cannot use import statement outside a module
- [Solved] mybatis plus Error: Invalid bound statement (not found)