SQL Fiddle 和 Oracle NOVA 之间的区别
Difference Between SQL Fiddle and Oracle NOVA
我有以下表格:
CREATE TABLE CUSTOMERS
(customerID INT PRIMARY KEY,
customerFullName VARCHAR(20) NOT NULL);
CREATE TABLE VEHICLES
(vehicleVIN VARCHAR(25) PRIMARY KEY,
vehicleMake VARCHAR(15) NOT NULL);
CREATE TABLE SALES
(saleID INT PRIMARY KEY,
customerID INT,
vehicleVIN VARCHAR(25));
CONSTRAINT SALES_FK1 FOREIGN KEY (customerID) REFERENCES CUSTOMERS(customerID),
CONSTRAINT SALES_FK2 FOREIGN KEY (vehicleVIN) REFERENCES VEHICLES(vehicleVIN));
并对这些表中的 运行 构建了以下查询:
SELECT VEHICLES.vehicleMake, CUSTOMERS.customerFullName
FROM SALES
JOIN CUSTOMERS on SALES.customerID = CUSTOMERS.customerID
JOIN(
SELECT SALES.vehicleVIN, VEHICLES.vehicleMake
FROM SALES
JOIN VEHICLES ON SALES.vehicleVIN = VEHICLES.vehicleVIN
GROUP BY SALES.vehicleVIN, VEHICLES.vehicleMake
HAVING COUNT(SALES.vehicleVIN) >= ALL
(SELECT COUNT(SALES.vehicleVIN)
FROM SALES
INNER JOIN VEHICLES ON SALES.vehicleVIN=VEHICLES.vehicleVIN
GROUP BY VEHICLES.vehicleMake))
VEHICLES ON SALES.vehicleVIN = VEHICLES.vehicleVIN
ORDER BY CUSTOMERS.customerFullName;
当我 运行 在 SQL Fiddle 中执行此操作时,它会完美执行并提供正确的输出(一列显示购买次数最多的车辆品牌,另一列显示显示购买该车辆品牌的每个人的客户全名)。
当我在 NOVA (Oracle) 中 运行 它时,它只是说 "No Rows Selected" 两者之间的语法有区别吗?我需要更改代码吗?谢谢!
自己回答。我在 SQL Fiddle 和 NOVA 之间的插入语句中提取数据时存在细微差异。问题是我的错,据我所知,一切正常。
我在 SQL fiddle 中的插入语句重新使用了一些车辆 VIN 号码,这有助于我编写的查询成功,但是查询不正确我正在努力完成。打开另一个问题来讨论该特定问题。
底线:我认为 NOVA DB 语法和 SQL Fiddle 语法之间没有任何重大差异。一切都很好!
我有以下表格:
CREATE TABLE CUSTOMERS
(customerID INT PRIMARY KEY,
customerFullName VARCHAR(20) NOT NULL);
CREATE TABLE VEHICLES
(vehicleVIN VARCHAR(25) PRIMARY KEY,
vehicleMake VARCHAR(15) NOT NULL);
CREATE TABLE SALES
(saleID INT PRIMARY KEY,
customerID INT,
vehicleVIN VARCHAR(25));
CONSTRAINT SALES_FK1 FOREIGN KEY (customerID) REFERENCES CUSTOMERS(customerID),
CONSTRAINT SALES_FK2 FOREIGN KEY (vehicleVIN) REFERENCES VEHICLES(vehicleVIN));
并对这些表中的 运行 构建了以下查询:
SELECT VEHICLES.vehicleMake, CUSTOMERS.customerFullName
FROM SALES
JOIN CUSTOMERS on SALES.customerID = CUSTOMERS.customerID
JOIN(
SELECT SALES.vehicleVIN, VEHICLES.vehicleMake
FROM SALES
JOIN VEHICLES ON SALES.vehicleVIN = VEHICLES.vehicleVIN
GROUP BY SALES.vehicleVIN, VEHICLES.vehicleMake
HAVING COUNT(SALES.vehicleVIN) >= ALL
(SELECT COUNT(SALES.vehicleVIN)
FROM SALES
INNER JOIN VEHICLES ON SALES.vehicleVIN=VEHICLES.vehicleVIN
GROUP BY VEHICLES.vehicleMake))
VEHICLES ON SALES.vehicleVIN = VEHICLES.vehicleVIN
ORDER BY CUSTOMERS.customerFullName;
当我 运行 在 SQL Fiddle 中执行此操作时,它会完美执行并提供正确的输出(一列显示购买次数最多的车辆品牌,另一列显示显示购买该车辆品牌的每个人的客户全名)。
当我在 NOVA (Oracle) 中 运行 它时,它只是说 "No Rows Selected" 两者之间的语法有区别吗?我需要更改代码吗?谢谢!
自己回答。我在 SQL Fiddle 和 NOVA 之间的插入语句中提取数据时存在细微差异。问题是我的错,据我所知,一切正常。
我在 SQL fiddle 中的插入语句重新使用了一些车辆 VIN 号码,这有助于我编写的查询成功,但是查询不正确我正在努力完成。打开另一个问题来讨论该特定问题。
底线:我认为 NOVA DB 语法和 SQL Fiddle 语法之间没有任何重大差异。一切都很好!