SELECT sum(pa.depositmade_num) as NumDeposit, sum(pa.depositmade_amt) as AmtDeposit,
count(distinct pa.userid) as distinctUser
FROM customer_profile cp
INNER JOIN player_activity pa
on cp.userID = pa.userID
WHERE pa.txndate > date(CURDATE()) - INTERVAL 14 day
HAVING (SELECT (Round(sum(opa.totalhold - opa.playercomps - opa.freemoney
- (opa.depositmade_amt*.1)),2)) > 20000
FROM player_activity opa
WHERE opa.userID = cp.userid)
我在mySQL中使用了同样的语句而没有问题。
但是,我现在收到unknown column datawarehouse.cp.userID in where clause
错误消息。
当我从子查询中删除WHERE opa.userID = cp.userid
时,查询会运行。但我需要该行才能使计算正常工作。