Hibernate Query 3嵌套选择

时间:2017-01-18 10:19:42

标签: jquery hibernate hql

如何修复当前工作的查询?

Query query = getSession().createQuery(
    "FROM Rates WHERE amount = 
        (SELECT MIN(amount) FROM
            (SELECT amount FROM Rates
            GROUP BY amount having COUNT(*) = 1))"); 

IntellijIDE编译器显示

')', ',', FETCH, GROUP, HAVING, IN, ORDER, WHERE or identifier expected, got '(

并在此FROM (SELECT

下划线红线(

1 个答案:

答案 0 :(得分:0)

如果我理解您的请求,您可以尝试:

"FROM Rates r1 WHERE r1.amount in 
    (SELECT MIN(r2.amount) FROM Rates r2
        GROUP BY r2.amount having COUNT(r2.amount) = 1))"

告诉我它是否正常