select a.*,b.inv_weight from (select a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id,sum(isnull(b.o_y_weight,b.o_weight)) as o_weight,sum(b.o_y_weight) as o_y_weight,sum(isnull(b.o_y_money_sum,b.o_money_sum)) as money_sum
from p_order as a left join p_orderlist as b on a.o_id=b.o_id where a.is_print is not null group by a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id) as a left join invoice as b
on a.o_id=b.o_id and a.p_id=b.p_id and isnull(a.o_y_weight,a.o_weight) <> b.inv_weight 为什么查不出数据 不加最后一个条件是可以查出数据的 问题出现在最后一个<> 用=也是可以查出数据 谁能帮我解决下
from p_order as a left join p_orderlist as b on a.o_id=b.o_id where a.is_print is not null group by a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id) as a left join invoice as b
on a.o_id=b.o_id and a.p_id=b.p_id and isnull(a.o_y_weight,a.o_weight) <> b.inv_weight 为什么查不出数据 不加最后一个条件是可以查出数据的 问题出现在最后一个<> 用=也是可以查出数据 谁能帮我解决下
select a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id,
sum(isnull(b.o_y_weight,b.o_weight)) as o_weight,sum(b.o_y_weight) as o_y_weight,
sum(isnull(b.o_y_money_sum,b.o_money_sum)) as money_sum
from p_order as a left join p_orderlist as b on a.o_id=b.o_id
where a.is_print is not null group by a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id
查出了什么内容,再判断与外面另一个表连接的时候是否能有符合条件的记录.
and COALESCE(a.o_y_weight,a.o_weight,0) <> COALESCE(b.inv_weight ,0)
from p_order as a left join p_orderlist as b on a.o_id=b.o_id where a.is_print is not null group by a.o_id,a.o_datetime,a.o_dept,b.p_name,b.p_size,b.p_id) as a left join invoice as b
on a.o_id=b.o_id and a.p_id=b.p_id and isNull(isnull(a.o_y_weight,a.o_weight),0) <> isdNull(b.inv_weight,0)