Whether the original method of laravel can join subqueries

The granularity of the data stored in the

table is relatively fine, so you need to make statistics according to the two fields in the table.

select B.col2,count(col2),sum(t.num)
from (
    select col1,col2,count(col3) as num
    from A
    where A.status = 1
    group by A.col2
) as t
left join B on t.col1 = B.col1
group by col1
Feb.27,2021

of course. You can take a look at this article. I hope it will be helpful to you.

Laravel Query Builder complex query case: subquery implements partition query partition by

Menu