有条件有未知条款

时间:2016-08-29 07:05:49

标签: mysql sql

 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时,查询会运行。但我需要该行才能使计算正常工作。

0 个答案:

没有答案