如何在sql内连接转换为yii活动记录?

时间:2012-10-18 10:21:41

标签: php oracle yii

如何将此查询转换为Yii活动记录?

SELECT a.USERID, a.ADID, a.PAGEVIEW,a.EXPIRYDATE,a.ADTITLE,a.ADDESC
        from CKAD a INNER JOIN 
        (
            SELECT  b.USERID, max(b.PAGEVIEW) as PAGEVIEW
            FROM CKAD b WHERE b.DISPPUBLISHDATE >= current_date - 3
            AND b.EXPIRYDATE >= current_date and b.STATUS = 1 AND b.USERID IS NOT NULL
            GROUP BY b.USERID
        ) b
        ON (a.USERID = b.USERID and a.PAGEVIEW = b.PAGEVIEW)
        order by a.PAGEVIEW DESC";

0 个答案:

没有答案