-3

我相信问题就在(旁边,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;
4

1 回答 1

2

在您的查询中,您没有用逗号分隔要返回的列。该SELECT语句的一般语法需要它们:

create view order_total as

SELECT   order_num,
         sum (quoted_price * num_ordered) AS total_amount
FROM     order_line
GROUP BY order_num;

(停止忘记逗号的一个好方法是将它们放在行的开头,而不是结尾,如下所示:

SELECT column1
       ,column2
       ,etc.
FROM   table

--通过将列放在行前而不中断查询,也可以非常简单地快速注释列。)

于 2013-03-24T22:56:05.453 回答