目前正致力于SSH安全shell代码,不断提供此错误代码。我已经尝试更改表名但仍然,我收到此错误。帮助!
以下是问题所在:
列出以超过任何其他产品的订单销售的产品的产品ID,产品名称和产品价格(基于订单出现次数,而不是数量)。将价格格式化为货币,并使用以下列标题:ProductID,Name,Price。
列出每个类别中价格最低的产品的类别ID,产品ID,产品名称和产品价格。将价格格式化为货币,并使用以下列标题:Cat_ID,Prod_ID,Prod_Name,Price。
以下是包含错误的代码:
SQL> --question 15
SQL>
SQL> SELECT Pro.ProductID as ProductID, Pro.ProductName AS Name, to_char(Pro.ProductPrice,'$99.99') AS Price
2 FROM Product_mys Pro
3 WHERE Pro.ProductPrice = (SELECT MAX(Pro.ProductPrice)
4 FROM OrderDetail_mys Pro);
WHERE Pro.ProductPrice = (SELECT MAX(Pro.ProductPrice)
*
ERROR at line 3:
ORA-00904: "PRO"."PRODUCTPRICE": invalid identifier
SQL>
SQL> --question 16
SQL>
SQL> SELECT Cat.CatID as Cat_ID,Pro.ProductID as Prod_ID, Pro.ProductName AS Prod_Name, to_char(Pro.ProductPrice,'$99.99') AS Price
2 FROM Category_mys Cat,Product_mys Pro
3 WHERE Pro.ProductPrice = (SELECT MIN(Pro.ProductPrice)
4 FROM OrderDetail_mys Pro);
WHERE Pro.ProductPrice = (SELECT MIN(Pro.ProductPrice)
*
这些是我用于值
的模式表CREATE TABLE Dept_mys (
DeptID Number(3) NOT NULL,
DeptName VARCHAR(20) NOT NULL,
PRIMARY KEY (DeptID)
) ;
CREATE TABLE Commission_mys (
CommClass CHAR(1) NOT NULL,
CommRate Number(2,2) NOT NULL,
PRIMARY KEY (CommClass)
) ;
CREATE TABLE Category_mys (
CatID Number(3) NOT NULL,
catName VARCHAR(20) NOT NULL,
PRIMARY KEY (CatID)
) ;
CREATE TABLE SalesRep_mys (
SalesRepID NUMBER(4) NOT NULL,
SalesRepFName VARCHAR(20) NOT NULL,
SalesRepLName VARCHAR(20) NOT NULL,
DeptID NUMBER(3) NOT NULL,
CommClass CHAR(1) NOT NULL,
PRIMARY KEY (SalesRepID),
FOREIGN KEY (DeptID) REFERENCES Dept_mys,
FOREIGN KEY (CommClass) REFERENCES Commission_mys
) ;
CREATE TABLE Customer_mys (
CustID CHAR(5) NOT NULL,
CustFName VARCHAR(20) NOT NULL,
CustLName VARCHAR(20) NOT NULL,
CustPhone CHAR(10),
SalesRepID NUMBER(4) NOT NULL,
PRIMARY KEY (CustID),
FOREIGN KEY (SalesRepID) REFERENCES SalesRep_mys
) ;
CREATE TABLE Order_mys (
OrderID NUMBER(3) NOT NULL,
OrderDate DATE NOT NULL,
CustID CHAR(5) NOT NULL,
PRIMARY KEY (OrderID),
FOREIGN KEY (CustID) REFERENCES Customer_mys
) ;
CREATE TABLE Product_mys (
ProductID NUMBER(3) NOT NULL,
ProductName VARCHAR(30) NOT NULL,
CatID Number(3) NOT NULL,
PRIMARY KEY (ProductID),
FOREIGN KEY (CatID) REFERENCES Category_mys
) ;
CREATE TABLE OrderDetail_mys (
OrderID NUMBER(3) NOT NULL,
ProductID NUMBER(3) NOT NULL,
ProductQty NUMBER(4) NOT NULL,
ProductPrice NUMBER(6,2) NOT NULL,
PRIMARY KEY (OrderID, ProductID),
FOREIGN KEY (OrderID) REFERENCES Order_mys,
FOREIGN KEY (ProductID) REFERENCES Product_mys
) ;
答案 0 :(得分:0)
您尝试使用ProductPrice
中没有该列的Product_mys
。