我正在尝试获取每个用户的最新交易。 因此,我尝试将自我联接与最新时间戳一起使用。
当我在postgresql中执行相同的查询时,它工作正常,但是在java(休眠)中尝试时,它给出以下错误。
java.lang.IllegalArgumentException:
org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:(在第1行第76列附近[SELECT a FROM BillingTransactionHistory a,(SELECT max(timeStamp)btimeStamp,appUserId bappUserId FROM BillingTransactionHistory b group by appUserId)) = bappUserId和a.timeStamp = btimeStamp和a.appUserId IN:hrIds和a.balance> = 1]
我的查询是
df.loc[mask, 'call_status'] = 'answered'
print (df)
data__id call_status rank
0 1 answered 1
1 1 answered 2
2 1 answered 3
3 2 answered 1
4 2 answered 2
5 3 not_answered 1
6 4 answered 1
7 4 answered 2
8 5 not_answered 1
9 5 not_answered 2
代码段是
SELECT a FROM BillingTransactionHistory a,(SELECT max(timeStamp) timeStamp, appUserId FROM BillingTransactionHistory b group by appUserId ) b WHERE a.appUserId = b.appUserId AND a.timeStamp=b.timeStamp
任何人都可以帮助我,如何解决它。