SELECT DISTINCT LOWER:SUBSTR

时间:2013-07-17 12:07:52

标签: sql ms-access ms-access-2010

我很难解决我的请求:

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

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:-1)

SQL中的字符串连接是||,而不是+。另外请记住使用单引号'引用字符串文字,而不是双引号"

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

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