SQL Server查询错误:“缺少或不完整的select语句”

时间:2011-03-08 10:38:13

标签: sql sql-server-2005

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

错误:

  

缺少或不完整的选择陈述

3 个答案:

答案 0 :(得分:3)

你有没有忘记CASE声明结尾处的END关键字?

IE中。

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

答案 1 :(得分:0)

尝试

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

答案 2 :(得分:0)

查询可能是这样的,

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

试试这个。