简体   繁体   English

SQL Fiddle和Oracle NOVA之间的区别

[英]Difference Between SQL Fiddle and Oracle NOVA

I have the following tables: 我有以下表格:

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));

And built the following query to run off of these tables: 并构建了以下查询以运行这些表:

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;

When I run this in SQL Fiddle, it executes perfectly and provides the correct output (one column that displays the vehicleMake that was purchased the most, and another column that displays the customerFullName of everyone who purchased that vehicleMake). 当我在SQL Fiddle中运行此代码时,它会完美执行并提供正确的输出(一列显示购买量最多的vehicleMake,另一列显示购买该载具的每个人的customerFullName)。

When I run it in NOVA (Oracle), It just says "No Rows Selected" Is there a difference in syntax between the two? 当我在NOVA(Oracle)中运行它时,它只是说“未选择行”两者在语法上有区别吗? Do I need to change my code? 我需要更改代码吗? Thanks! 谢谢!

Answered myself. 回答自己。 I was pulling the data with a minor discrepancy in my insert statements between SQL Fiddle and NOVA. 我在SQL Fiddle和NOVA之间的插入语句中拉出数据时,存在微小差异。 The issue was my fault, and from what I can tell now, all is performing as it should. 问题是我的错,从我现在可以看出,一切都在按预期进行。

My insert statements in SQL fiddle were re-using a few vehicleVIN numbers, which was contributing to the success of the query that I had written, however the query is not correct for what I am trying to accomplish. 我在SQL小提琴中的insert语句正在重新使用一些vehicleVIN编号,这有助于我编写的查询成功,但是该查询对于我要完成的工作是不正确的。 Opened another question to discuss that specific issue. 提出了另一个问题来讨论该特定问题。

Bottom line: I do not believe they are any major differences between the NOVA DB syntax and the SQL Fiddle syntax. 底线:我不认为它们是NOVA DB语法和SQL Fiddle语法之间的主要区别。 All is good! 一切都很好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM