I'm working in Spring for a college project. I have to develop a system that allow users to create "meetings". I've mapped the relationship between User and Rendezvous(Meeting) like this:
User (1) <--- (0...*) Rendezvous
@Entity
@Access(AccessType.PROPERTY)
public class Rendezvous extends DomainEntity {
private User user;
@NotNull
@Valid
@ManyToOne(optional = false)
public User getUser() {
return this.user;
}
public void setUser(final User user) {
this.user = user;
}
}
I need to know the average and the standard deviation of rendezvouses created per each user, so I'm trying to create a query to do that.
I need to make an equivalent query to this one in mySQL but in JPQL
select avg(rendezvouses) from (
select user_id, count(*) as rendezvouses
from rendezvous group by user_id
) nestedQuery;