I want to lowercase all users usernames, then count how many distinct ones there are, but getting an error on this hql query:

```
select count(distinct lower(user.username)) from UserEntity as user

org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found 'user' near line 1, column 29 [select count(distinct lower(user.username)) 

```

This works fine:

```
select count(distinct user.username) from UserEntity as user

```

But when I add the lower(...) it it fails, any help is much appreciated!