我有一个复杂的连接查询,我无法使用Laravel查询构建器创建,
RAW表达式如下:
select r.counted,day (date) as day, month (date) as month, year (date) from dates
left join (select created_at,COUNT(created_at) counted ,day (created_at) as day, month (created_at) as month, year (created_at) as year from analytics
where type = 1
and project_id = 1
group by `year`, `month`, `day`
order by `year` desc) r
on `dates`.`date` = DATE_FORMAT(r.created_at, '%Y-%m-%d')
where `date` between '2015-01-01' and '2015-02-01'
基本上我希望它能够按天计算所有分析,并获得没有价值的日期
我有模型date
和模型analytic
analytic
已有范围scopeProject
和scopeType
过滤初始数据
谢谢!