जैसे ही त्रुटि कहती है, CREATE VIEW कथन को क्वेरी बैच में एकमात्र कथन होना चाहिए।
इस परिदृश्य में आपके पास दो विकल्प हैं, जो उस कार्यक्षमता पर निर्भर करता है जिसे आप प्राप्त करना चाहते हैं:
-
CREATE VIEWरखें शुरुआत में क्वेरी करेंCREATE 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 ) -
GOका उपयोग करें CTE के बाद औरCREATE VIEW. से पहले क्वेरी-- विकल्प #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;