34,587
社区成员
发帖
与我相关
我的任务
分享
create table #tmp001(rowid int identity(1,1),id int,listdate datetime,amount decimal(18,4),getamount decimal(18,4))
insert into #tmp001(id,listdate,amount)
select id,listdate,amount
from t_wh_billofdocument as p
left join #billofdocument_receivables as p1 on p.id=p1.wh_billofdocument_id
WHERE convert(datetime,convert(varchar(10),p.listdate))<@lastdate1
and p.bs_customer_id=@bs_customer_id
union all
select id,listdate,amount
from t_wh_gatheringpayment
where type=1
and convert(datetime,convert(varchar(10),listdate))<@lastdate1
and bs_customer_id=@bs_customer_id
select id,listdate,amount
into #tmp002
from #tmp001 order by listdate
select * from #tmp002
select id,listdate,amount
from #tmp001 order by listdate