1

我在解决我的请求时遇到了困难:

SELECT DISTINCT LOWER (CustomerName), 
  SUBSTR(Customer.PostalCode, 1, 3) +" "+ SUBSTR(Customer.PostalCode,4,6)AS'postal' 
FROM Customer
ORDER BY Customer.CuName

我收到消息:未找到预期的词法元素

这个完美无缺。

SELECT DISTINCT Customer.Name, Customer.PostalCode AS'postal' 
FROM Customer
ORDER BY Customer.CuName

有人可以帮忙吗?

4

2 回答 2

0
SELECT DISTINCT 
                LOWER (CustomerName), 
                SUBSTR(Customer.PostalCode, 1, 3) + ' ' +   
                SUBSTR(Customer.PostalCode, 4, 6) AS 'postal' 
FROM 
     Customer 
ORDER BY 
      Customer.CuName
于 2013-07-17T12:11:50.690 回答
-1

SQL 中的字符串连接是||,不是+。还要记住用单引号'而不是双引号来引用您的字符串文字"

尝试按如下方式重写您的查询:

SELECT DISTINCT LOWER (CustomerName),
                SUBSTR(Customer.PostalCode, 1, 3) || ' ' ||
                  SUBSTR(Customer.PostalCode,4,6) AS 'postal' 
FROM Customer
ORDER BY Customer.CuName
于 2013-07-17T12:12:14.330 回答