1 2 ZY010001107189 4 1 1 -28763.05
2 1 ZY010001107189 3 1 1 28763.05
这是我查询出来的语句,可是其实因为-28763.05与28763.05之和为零,我想写一条语句,要是他们之和为零就检索不到。这样的sql语句怎么样写呢?都是在同一个表格的
select *
from fin_ipb_balancehead h
where h.inpatient_no = 'ZY010001107189'
and h.balance_type = 'I'
and h.waste_flag = '0'
2 1 ZY010001107189 3 1 1 28763.05
这是我查询出来的语句,可是其实因为-28763.05与28763.05之和为零,我想写一条语句,要是他们之和为零就检索不到。这样的sql语句怎么样写呢?都是在同一个表格的
select *
from fin_ipb_balancehead h
where h.inpatient_no = 'ZY010001107189'
and h.balance_type = 'I'
and h.waste_flag = '0'
-28763.05
28763.05
是QTY
select *
from fin_ipb_balancehead h
where h.inpatient_no = 'ZY010001107189'
and h.balance_type = 'I'
and h.waste_flag = '0'
and inpatient_no in (select inpatient_no
from fin_ipb_balancehead
where havingsum(qty)<> 0
group by inpatient_no)
select inpatient_no
from fin_ipb_balancehead h
where h.inpatient_no = 'ZY010001107189'
and h.balance_type = 'I'
and h.waste_flag = '0'
group by inpatient_no having sum(你的数据字段)<>0);表结构不描述,请看置顶贴提问的智慧!
select inpatient_no
from fin_ipb_balancehead h
where h.inpatient_no = 'ZY010001107189'
and h.balance_type = 'I'
and h.waste_flag = '0'
group by inpatient_no having sum(你的数据字段)<>0);