php laravel db leftjoin 一个数据集的写法

$_query = DB::table(‘a as o’)

        ->leftJoin(DB::raw("(  select id,count( user_id ) AS click,
                                    count( DISTINCT user_uid ) AS only_click from  `aa`
                                    where  `click_dt` >= '$start_date'
                                    AND `click_dt` <= '$end_date' 
                                    GROUP BY source_id ) as cli"),'aa.source_id','=','o.itemId')

        ->where('o.Time','>=',$start_date.' 00:00:00')
        ->where('o.Time','<=',$end_date.' 23:59:59')
        ->where('o.status','!=',13);

你可能感兴趣的:(php laravel db leftjoin 一个数据集的写法)