SQL 具体查询更正
SQL specific Query Correction
谁能告诉我,这个查询有什么问题,我是使用 Oracle APEX 的学生。我收到此错误:ORA-00918:列定义不明确
SELECT t.BandDesc, TypeDesc, CustomerID, PaymentAmount, TotalPayment FROM
(SELECT Room_Dim.BandDesc, Room_Dim.TypeDesc, CustomerID, PaymentAmount
FROM Room_Dim, Fact_Bookings_Payments
WHERE Room_Dim.RoomID = Fact_Bookings_Payments.RoomID)t
LEFT JOIN
(SELECT ConcertID, CustomerID, TotalPayment
FROM Fact_Buy)t2
ON t.CustomerID = t2.CustomerID;
我需要找到:对于每个房间乐队和音乐会,产生 4 星 TypeDesc 房间的累计收入
t
和 t2
都有一个 CustomerId
并且您在连接条件中使用它;但是,在第一行你 select CustomerId
没有指定它来自哪个 table。这可能是错误的来源。
SELECT t.BandDesc,
TypeDesc,
t.CustomerID, -- Either this
t2.CustomerID, -- Or this
PaymentAmount,
TotalPayment
FROM (
SELECT Room_Dim.BandDesc,
Room_Dim.TypeDesc,
CustomerID,
PaymentAmount
FROM Room_Dim
INNER JOIN Fact_Bookings_Payments
ON Room_Dim.RoomID = Fact_Bookings_Payments.RoomID
) t
LEFT JOIN (
SELECT ConcertID, CustomerID, TotalPayment
FROM Fact_Buy
) t2
ON t.CustomerID = t2.CustomerID;
谁能告诉我,这个查询有什么问题,我是使用 Oracle APEX 的学生。我收到此错误:ORA-00918:列定义不明确
SELECT t.BandDesc, TypeDesc, CustomerID, PaymentAmount, TotalPayment FROM
(SELECT Room_Dim.BandDesc, Room_Dim.TypeDesc, CustomerID, PaymentAmount
FROM Room_Dim, Fact_Bookings_Payments
WHERE Room_Dim.RoomID = Fact_Bookings_Payments.RoomID)t
LEFT JOIN
(SELECT ConcertID, CustomerID, TotalPayment
FROM Fact_Buy)t2
ON t.CustomerID = t2.CustomerID;
我需要找到:对于每个房间乐队和音乐会,产生 4 星 TypeDesc 房间的累计收入
t
和 t2
都有一个 CustomerId
并且您在连接条件中使用它;但是,在第一行你 select CustomerId
没有指定它来自哪个 table。这可能是错误的来源。
SELECT t.BandDesc,
TypeDesc,
t.CustomerID, -- Either this
t2.CustomerID, -- Or this
PaymentAmount,
TotalPayment
FROM (
SELECT Room_Dim.BandDesc,
Room_Dim.TypeDesc,
CustomerID,
PaymentAmount
FROM Room_Dim
INNER JOIN Fact_Bookings_Payments
ON Room_Dim.RoomID = Fact_Bookings_Payments.RoomID
) t
LEFT JOIN (
SELECT ConcertID, CustomerID, TotalPayment
FROM Fact_Buy
) t2
ON t.CustomerID = t2.CustomerID;