SQL Server query error: “Missing or incomplete select statement”

让人想犯罪 __ 提交于 2019-12-25 15:52:31

问题


SELECT 
    Id, Product, 
    [fare] = CASE WHEN @date BETWEEN s1from AND s1to THEN s1rate ELSE fare 
FROM Table1

Error:

Missing or incomplete select statement


回答1:


Haven't you forgot the END keyword at the end of CASE statement?

Ie.

SELECT 
    Id, Product, 
    [fare] = CASE WHEN @date BETWEEN s1from AND s1to THEN s1rate ELSE fare END
FROM Table1



回答2:


Try

SELECT Id, Product, [fare] =
CASE @date
WHEN BETWEEN s1from AND s1to THEN s1rate 
ELSE fare
END
FROM Table1



回答3:


The query might be like this,

Select Id, Product, (case when @date between s1from and s1to then s1rate else fare end)as fare from  Table1.

Try this.



来源:https://stackoverflow.com/questions/5231310/sql-server-query-error-missing-or-incomplete-select-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!