declare @batchno varchar(40),@tranno int
select @tranno=4342
select @batchno =(select top 1 batchno from issue where tranno=@tranno)
select i.tranno,i.trandate,i.pcs,i.grswt,i.netwt,i.tagno from issue as i
inner join receipt r on r.batchno=@batchno and i.grswt=r.grswt
where i.batchno in
(select batchno from customerinfo where psno in
(
select psno from customerinfo where batchno in (select batchno from issue where tranno=@tranno)
)
)
select @tranno=4342
select @batchno =(select top 1 batchno from issue where tranno=@tranno)
select i.tranno,i.trandate,i.pcs,i.grswt,i.netwt,i.tagno from issue as i
inner join receipt r on r.batchno=@batchno and i.grswt=r.grswt
where i.batchno in
(select batchno from customerinfo where psno in
(
select psno from customerinfo where batchno in (select batchno from issue where tranno=@tranno)
)
)