I have been working on this for a few days and cannot figure out where the error is. The query is:
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;
I keep getting:
SQL Error: ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis".
I cannot find the issue. Any help would be much appreciated. Here is what the table and insert statement looks like.
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);
As a side note, I did try it this way as well:
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;