SQL1:
select count ( ? ) from ( select c . c_id , c . c_d_id , c . c_w_id , c . c_balancec1 , ( select sum ( ol_amount ) from orders , order_line where ol_w_id = o_w_id and ol_d_id = o_d_id and ol_o_id = o_id and ol_delivery_d is not ? and o_w_id = ? and o_d_id = c . c_d_id and o_c_id = c . c_id ) sm , ( select sum ( h_amount ) from history where h_c_w_id = ? and h_c_d_id = c . c_d_id and h_c_id = c . c_id ) smh from customerc where c . c_w_id = ? ) t where c1 <> sm - smh
SQL2:
select count ( ? ) from ( select c . c_id , c . c_d_id , c . c_balancec1 , c_ytd_payment , ( select sum ( ol_amount ) from orders , order_line where ol_w_id = o_w_id and ol_d_id = o_d_id and ol_o_id = o_id and ol_delivery_d is not ? and o_w_id = ? and o_d_id = c . c_d_id and o_c_id = c . c_id ) sm from customerc where c . c_w_id = ? ) t1 where c1 + c_ytd_payment <> sm
可以从 slow query log 中取两条完整的对于这个 sql 的内容吗?
select count ( ? ) from ( select c . c_id , c . c_d_id , c . c_w_id , c . c_balancec1 , ( select sum ( ol_amount ) from orders , order_line where ol_w_id = o_w_id and ol_d_id = o_d_id and ol_o_id = o_id and ol_delivery_d is not ? and o_w_id = ? and o_d_id = c . c_d_id and o_c_id = c . c_id ) sm , ( select sum ( h_amount ) from history where h_c_w_id = ? and h_c_d_id = c . c_d_id and h_c_id = c . c_id ) smh from customerc where c . c_w_id = ? ) t where c1 <> sm - smh