gpt4 book ai didi

mysql - 在 HQL 中减去子选择值

转载 作者:行者123 更新时间:2023-11-30 23:25:37 26 4
gpt4 key购买 nike

我正在使用 Hibernate,我想从两个不同的子查询中获取的两个值中减去,但我收到以下错误:

SQLGramarEception: could not execute query

SELECT termQuery.term.id,
(SELECT COALESCE(MIN(termResult2.position),101) FROM termQuery2.results termResult2 WHERE termResult2.url.hostname MEMBER subscription.account.domains) as **prevPosition**,
(SELECT COALESCE(MIN(termResult.position),101) FROM termQuery.results termResult WHERE termResult.url.hostname MEMBER subscription.account.domains) as **currentPosition**,
prevPosition - currentPosition as change --<<<<<<
FROM TermSubscription subscription, TermQuery termQuery, TermQuery termQuery2
WHERE subscription.account.id=1197
AND termQuery.term=subscription.term
AND termQuery.provider.id=2
AND termQuery.queryDate.yearWeek = '201242'
AND termQuery2.term=termQuery.term
AND termQuery2.provider.id=termQuery.provider.id
AND termQuery2.queryDate.yearWeek = '201241'
ORDER BY subscription.term.id, termQuery.queryDate.yearWeek

我知道不可能像那样减去这两个值,但我不知道如何做。那么,会有什么办法呢?谢谢

最佳答案

仅选择其他 3 个值,并在迭代查询结果时,用 Java 从 prevPosition 中减去 currentPosition

关于mysql - 在 HQL 中减去子选择值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com