Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MYSql使用HQL计算子查询的总金额_Mysql_Spring_Hibernate - Fatal编程技术网

MYSql使用HQL计算子查询的总金额

MYSql使用HQL计算子查询的总金额,mysql,spring,hibernate,Mysql,Spring,Hibernate,以上HQL不工作。。显示以下异常 意外标记:(靠近第1行第25列) HQL子查询只能出现在select或where子句中 例如,有效查询: @Query(value = "SELECT SUM(amount) FROM (SELECT t1.amount FROM Table1 t1 " + "INNER JOIN t1.table2 t2 " + "GROUP BY t1.txnId) a ") public double getAmo

以上HQL不工作。。显示以下异常

意外标记:(靠近第1行第25列)


HQL子查询只能出现在select或where子句中

例如,有效查询:

@Query(value = "SELECT SUM(amount) FROM (SELECT t1.amount FROM Table1 t1 " 
            + "INNER JOIN t1.table2 t2 "
            + "GROUP BY t1.txnId) a ")
    public double getAmount();

资料来源:

我建议使用本机查询代替HQL

select cat.id, (select max(kit.weight) from cat.kitten kit) from Cat as cat 
select c from DomesticCat as cat 
where cat.name not in (
   select name.nickName from Name as name )