SQL查询中的语法不正确'('

时间:2022-05-11 22:55:45

I believe the problem is near the ( next to quoted price as I get a syntax error of Incorrect syntax near '('. Any help with this would be greatly appreciated. Using Microsoft SQL-Server Management Studio.

我相信问题就在附近(在报价旁边,因为我在'('附近的语法错误中找到了错误的语法。对此有任何帮助将非常感激。使用Microsoft SQL-Server Management Studio。

create view order_total as

select order_num

sum (quoted_price * num_ordered) as total_amount

from order_line;

1 个解决方案

#1


1  

In your query, you haven't separated the columns you want to return by commas. The general syntax for the SELECT statement requires them:

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

create view order_total as

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

(A good way to stop forgetting comma's is by placing them at the start of the line, not at the end of them, as follows:

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

SELECT column1
       ,column2
       ,etc.
FROM   table

Makes it also very simple to quickly comment a column out by putting -- in front of the line without your query breaking.)

通过将行放在行前而不会导致查询中断,快速对列进行注释也非常简单。)

#1


1  

In your query, you haven't separated the columns you want to return by commas. The general syntax for the SELECT statement requires them:

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

create view order_total as

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

(A good way to stop forgetting comma's is by placing them at the start of the line, not at the end of them, as follows:

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

SELECT column1
       ,column2
       ,etc.
FROM   table

Makes it also very simple to quickly comment a column out by putting -- in front of the line without your query breaking.)

通过将行放在行前而不会导致查询中断,快速对列进行注释也非常简单。)

相关文章