Django aggregrate/annotate with additional join -


i have 2 model classes: class a represents table_a , class b represents table_b. there way aggregate or annotate class a include value of field in class b other column aggregated on?

the sql query accomplish need follows:

select   a.*,   b2.col2 table_a   left join (select                max(col1) m,                a_id              table_b              group a_id) b1 on b1.a_id = a.id   left join table_b b2 on b1.a_id = b2.a_id , b2.col1 = b1.m 

but aggregate function returns data retrieved this:

select   a.*,   b1.m table_a   left join (select                max(col1) m,                a_id              table_b              group a_id) b1 on b1.a_id = a.id 


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -