ALTER procedure [dbo].[test]
as
create table #temp(
keyid varchar(8),
artid varchar(8))
Insert Into #temp(keyid,artid)
select keyid,artid
from TC_KNEADBILL
where STATUS in (2)
and artid in (select min(artid) as artid from TC_KNEADBILL where Status = 2 group by BillID)
Insert Into #temp(keyid,artid)
select keyid,artid
from TC_KNEADBILL
where STATUS in (1)
and artid in (select min(artid) as artid from TC_KNEADBILL where Status = 1 group by BillID)
and KEYID not in (select KEYID from #temp)
Insert Into #temp(keyid,artid)
select distinct keyid,artid
from TC_Artbooking
where bookingtime in (select min(BookingTime) as bookingtime from TC_Artbooking where Status = 0 group by BillID)
and artid in (select min(artid) as artid from TC_Artbooking where Status = 0 group by BillID)
and KEYID not in (select KEYID from #temp)
select * from #temp
按优先级插入临时表的存储过程
最新推荐文章于 2021-09-24 11:37:12 发布