2017-03-20 1 views
0
select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
inner join OrderDetails as OD on OD.OrderID=O.OrderID 
inner join Products as P on OD.ProductID=P.ProductID 
inner join Customers as C on O.CustomerID=C.CustomerID 
group by OD.OrderID 
Order by TotalPrice 
limit 5 

ここに私のSQL文があります。それは私に '内部'構文エラーを与える... 私は問題を尋ねることはできますか?SQL ERROR "1 near 'inner'、構文エラー" W3Cサンプルデータベース

答えて

5

あなたのSQLステートメントはFROM句が欠落しています。

select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
FROM <your driving table here> 
inner ... 

はおそらく、あなたはOrdersから選択します:

select OD.orderID, C.CustomerName, O.OrderDate,   
    round(sum(P.Price*OD.Quantity)) as TotalPrice 
FROM Orders as O 
inner ... 
+0

ああ右、私の悪い、ということを示すために感謝します。 –