德比jpa选择MAX()

时间:2017-11-13 21:16:35

标签: jpa derby

我的查询有点问题。 我的表table 我想要这些行 rows

但我只得到一排 rows

这是我的查询:

        Query q = em.createQuery("SELECT OBJECT(historic) FROM Historic historic WHERE historic.user.id = :user_id AND historic.enchere.id = historic.enchere.id AND historic.limcoins = (SELECT MAX(historic.limcoins) FROM Historic historic WHERE historic.enchere.id = historic.enchere.id AND historic.state LIKE :state)");
        q.setParameter("user_id", user_id);
        q.setParameter("state", "none");
        List<Historic> list = q.getResultList();

1 个答案:

答案 0 :(得分:0)

好的,我找到了。

用IN

替换= oprator
historic.limcoins IN (SELECT MAX(historic.limcoins) FROM Historic historic WHERE historic.enchere.id = historic.enchere.id AND historic.state LIKE :state)