我正在使用 postresql,但我真的不擅长构建 sql 查询。我有这个查询,它的工作原理:
SELECT handhistories FROM handhistories
JOIN pokerhands using (pokerhand_id)
JOIN gametypes using (gametype_id)
RIGHT OUTER JOIN playerhandscashkeycolumns using (pokerhand_id)
WHERE pokerhands.site_id=0
AND pokerhands.numberofplayers>=5 and pokerhands.numberofplayers<=7
AND (bigblind = 2 OR bigblind = 4 )
AND player_id in
(SELECT player_id FROM playerhandscashkeycolumns GROUP BY player_id
HAVING AVG(case didvpip when true then 100::real else 0 end) <= 20 )
但我也想限制底部的最后一个“拥有”,所以它会是这样的,但它当然不起作用。
SELECT handhistories FROM handhistories
JOIN pokerhands using (pokerhand_id)
JOIN gametypes using (gametype_id)
RIGHT OUTER JOIN playerhandscashkeycolumns using (pokerhand_id)
WHERE pokerhands.site_id=0
AND pokerhands.numberofplayers>=5 and pokerhands.numberofplayers<=7
AND (bigblind = 2 OR bigblind = 4 )
AND player_id in
(SELECT player_id FROM playerhandscashkeycolumns GROUP BY player_id
HAVING AVG(case didvpip when true then 100::real else 0 end) <= 20
AND HAVING AVG(case didvpip when true then 100::real else 0 end) > 10 )
如何“保存”拥有之后的值,以便我也可以从底部进行比较?谢谢你们。