我不明白这个陈述中的错误。
Select customername,LEN(address)
FROM customers group by customername having LEN(address) = 13;
这是错误消息 HAVING子句(LEN(地址)= 13)没有分组或聚合。
答案 0 :(得分:4)
address
中LEN(address)
和GROUP BY
都不在。{1}}。因此,您需要添加它们或将表达式包装在聚合函数中:
SELECT customername, MAX(LEN(address))
FROM customers
GROUP BY customername
HAVING MAX(LEN(address)) = 13;
或者,如果您只想要长度为13的客户,则可能根本不需要聚合:
SELECT customername
FROM customers
WHERE LEN(address) = 13;
答案 1 :(得分:1)
尝试使用where子句
Select customername,LEN(address) as lenadressnamecolumn
FROM customers where LEN(address) = 13;