| 12345678910111213141516171819202122 |
- SELECT sum(zhutui_amount), sum(liandai_amount) from
- (
- select
- s.bill_no,sg.quantity*sg.sales_price as zhutui_amount
- from rbp.rbp_sales_order_bill s final
- left join rbp.rbp_sales_order_bill_goods sg on s.id = sg.bill_id
- left join rbp.rbp_sales_order_bill_size ss on s.id = ss.bill_id and sg.id = ss.bill_goods_id
- left join rbp.rbp_goods g on ss.goods_id = g.id
- left join rbp.rbp_color cl on ss.color_id = cl.id
- where g.code = 'g_code_holder' and cl.`code` = 'cl_code_holder' and sg.type = 0 and s.bill_date >= 'date_start_holder' and s.bill_date < 'date_end_holder'
- ) as zhutui_bill_no
- join
- (
- select
- s.bill_no,sg.quantity*sg.sales_price as liandai_amount
- from rbp.rbp_sales_order_bill s final
- left join rbp.rbp_sales_order_bill_goods sg on s.id = sg.bill_id
- left join rbp.rbp_sales_order_bill_size ss on s.id = ss.bill_id and sg.id = ss.bill_goods_id
- left join rbp.rbp_goods g on ss.goods_id = g.id
- left join rbp.rbp_color cl on ss.color_id = cl.id
- where ss.goods_id = goods_id_holder AND ss.color_id = color_id_holder and sg.type = 0 and s.bill_date >= 'date_start_holder' and s.bill_date < 'date_end_holder'
- ) as liandai_bill_no on zhutui_bill_no.bill_no = liandai_bill_no.bill_no
|