嘿,我是 JPA 的新手,对 SQL 还很陌生,我需要编写一个选择查询
我需要 :
“选择金额超过所有美元付款平均值的所有付款”
我有一个 JPA 实体:
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
private String account;
private double amount;
private String currency;
我试过:
@NamedQuery(name="payByUSD" , query="SELECT x FROM Payment x WHERE x.amount > (SELECT AVG(x.amount)from Payment)")
但我收到以下错误:
- The FROM clause must defined at least one identification variable declaration.
- The right expression is missing from the arithmetic expression.
谁能指出我正确的方向。