Reputation: 212
I dont understand whats wrong in this statment.
Select customername,LEN(address)
FROM customers group by customername having LEN(address) = 13;
This is the error message HAVING clause (LEN(address)=13) without grouping or aggregation.
Upvotes: 1
Views: 3449
Reputation: 16214
Try it with the where clause
Select customername,LEN(address) as lenadressnamecolumn
FROM customers where LEN(address) = 13;
Upvotes: 1
Reputation: 1270993
Neither address
nor LEN(address)
is in the GROUP BY
. So, you either need to add them or wrap the expressions in an aggregation function:
SELECT customername, MAX(LEN(address))
FROM customers
GROUP BY customername
HAVING MAX(LEN(address)) = 13;
Or if you just want customers with a length of 13, perhaps no aggregation is needed at all:
SELECT customername
FROM customers
WHERE LEN(address) = 13;
Upvotes: 4