1
我一直在爲此工作幾天,無法找出錯誤的位置。查詢是:SQL查詢提供了缺失的括號錯誤
Select distinct p.PkgID, p.PkgName, p.PkgCost, c.CustFName || ' ' || c.CustLName as "CUSTOMERNAME"
FROM Subscription s, Package p, Customer c
WHERE p.PkgID = s.PkgID
AND c.CustID = s.CustID
AND to_date
(s.StartDate, 'Mon DD, YYYY')=
to_date
(&StartDate, 'Mon DD, YYYY')
ORDER BY p.PkgID;
我不斷收到:
SQL Error: ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis".
我無法找到問題。任何幫助將非常感激。 這是表和插入語句的樣子。
CREATE TABLE SUBSCRIPTION
(
SubID NUMBER(5) NOT NULL CONSTRAINT SUBSCRIPTION_SubID_PK PRIMARY KEY,
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
CustID NUMBER(5) NOT NULL,
PkgID NUMBER(5) NOT NULL
);
ALTER TABLE SUBSCRIPTION ADD CONSTRAINT SUBSCRIPTION_CustID_FK FOREIGN KEY (CustID) REFERENCES CUSTOMER (CustID);
ALTER TABLE SUBSCRIPTION ADD CONSTRAINT SUBSCRIPTION_PkgID_FK FOREIGN KEY (PkgID) REFERENCES PACKAGE (PkgID);
INSERT INTO SUBSCRIPTION
VALUES (010, to_date('Jan 01, 2010 11:30','Mon DD, YYYY hh24:mi'), to_date('Jan 01, 2013 14:30','Mon DD, YYYY hh24:mi'), 00001, 10101);
INSERT INTO SUBSCRIPTION
VALUES (015,to_date('Mar 01, 2012 17:00','Mon DD, YYYY hh24:mi'), to_date('Dec 05, 2012 17:00','Mon DD, YYYY hh24:mi'), 00002, 20202);
作爲一個方面說明,我也嘗試這種方式還有:
Select distinct p.PkgID, p.PkgName, p.PkgCost, c.CustFName || ' ' || c.CustLName as "CUSTOMERNAME"
FROM Subscription s
Left OUTER JOIN Package p on p.PkgID = s.PkgID
Left OUTER JOIN Customer c on c.CustID = s.CustID
WHERE to_date (s.StartDate, 'Mon DD, YYYY')=
to_date (&StartDate, 'Mon DD, YYYY')
ORDER BY p.PkgID;
什麼是s.startdate的數據類型? –
您能否提供創建表的代碼並在其中插入一些數據? – Dilshod
S.StartDate是日期。 – Jim