我在做SQL时遇到语法错误

时间:2017-07-26 08:17:33

标签: sql

我在执行SQL时遇到语法错误

SELECT 
    Title AS 'Title of Item', 
    PubYear AS 'Year of Publication', 
    Round(ReplacementCost/1.1 AS 'ReplacementCost(Actual)', 1), 
    Round(LostFee/1.1 AS 'LostFee(Actual)', 1)

FROM Item

WHERE PubYear IN (2001, 2002)

2 个答案:

答案 0 :(得分:1)

MySQL中ROUND()函数的语法是:

ROUND( number, [ decimal_places ] )

你显然试图在ROUND()的调用中嵌入别名,这没有用。

更正版本:

SELECT 
    Title AS 'Title of Item', 
    PubYear AS 'Year of Publication', 
    Round(ReplacementCost/1.1, 1) AS 'ReplacementCost(Actual)', 
    Round(LostFee/1.1, 1) AS 'LostFee(Actual)'
FROM Item
WHERE PubYear IN (2001, 2002)

答案 1 :(得分:0)

你可以试试这个:

SELECT
Title AS 'Title of Item',
PubYear AS 'Year of Publication', 
Round(ReplacementCost/1.1, 1)  AS 'ReplacementCost(Actual)', 
Round(LostFee/1.1 , 1) AS 'LostFee(Actual)'

FROM Item

WHERE PubYear IN (2001, 2002)

我不知道这是否可以解决您的问题,但由于我无法发表评论,我发帖是为了帮助。