我正在尝试运行 SQL 语句,但出现语法错误

问题描述 投票:0回答:1

结果:“类型”附近:语法错误 第 2 行:

选择 发票日期, 帐单地址, 比林城, 全部的, 案件 当总计 < 2.00 THEN 'Baseline Purchase' ELSE 'Top Performer' END AS Purchase Type FROM Invoice WHERE Purchase Type = 'Top Performer' ORDER BY BillingCity

sql database sqlite syntax-error case
1个回答
0
投票

列名称或别名中不能有空格,就像

Purchase Type
中那样。您可以使用双引号 (
"
) 转义此名称:

SELECT   InvoiceDate, BillingAddress, BillingCity, total, 
         CASE WHEN total < 2.00 THEN 'Baseline Purchase' 
              ELSE 'Top Performer' 
         END AS "Purchase Type"
         -- Here^-------------^ 
FROM     Invoice 
WHERE    Purchase Type = 'Top Performer'
ORDER BY BillingCity
© www.soinside.com 2019 - 2024. All rights reserved.