我相信這個問題是近(
旁邊quoted price
我得到的Incorrect syntax near '('
一個語法錯誤。任何幫助,將不勝感激。使用Microsoft SQL-Server Management Studio中。附近有語法錯誤('
create view order_total as
select order_num
sum (quoted_price * num_ordered) as total_amount
from order_line;
我相信這個問題是近(
旁邊quoted price
我得到的Incorrect syntax near '('
一個語法錯誤。任何幫助,將不勝感激。使用Microsoft SQL-Server Management Studio中。附近有語法錯誤('
create view order_total as
select order_num
sum (quoted_price * num_ordered) as total_amount
from order_line;
在您的查詢,你有沒有分開你想用逗號返回列的SELECT
語句一般語法要求他們:
create view order_total as
SELECT order_num,
sum (quoted_price * num_ordered) AS total_amount
FROM order_line
GROUP BY order_num;
(一個好辦法來阻止forgett荷蘭國際集團逗號是通過將它們放置在該行的開始,而不是在他們的結束,具體如下:
SELECT column1
,column2
,etc.
FROM table
使得它也很簡單,通過把--
在該行的前面,而不可以快速地註釋一柱而出您的查詢中斷。)
而且您還需要從選擇列表中刪除'order_num',或者在查詢中添加'GROUP BY order_num'。 – 2013-03-24 22:58:24
謝謝,我確定使用Microsoft SQL Server Management Studio。我確實繼續並調整我的代碼以使逗號位於正確的位置,並且現在出現錯誤消息8120,級別16,狀態1,過程order_total,行2 列'order_line.ORDER_NUM'在選擇中無效列表,因爲它不包含在聚合函數或GROUP BY子句中。 – user2205669 2013-03-24 22:58:33
@ypercube:好點!在order_num上用「GROUP BY」編輯查詢。 – Josien 2013-03-24 22:58:56
'select order_num, sum ...' – Musa 2013-03-24 22:47:01
第一列('order_num')後面缺少逗號。 – halfer 2013-03-24 22:54:41