CREATE FUNCTION everday  ()
RETURNS  @temp1 table(pronum char(10),presort int,nowin int,nowout int,nowsort int)
AS  
BEGIN 
insert into @temp1(pronum,nowsort,presort) select a.pronum,nowsort=a.number,presort=b.number from pro_product a left outer join pro_daynumber b on a.pronum=b.pronum where b.modtime=(select max(modtime) from pro_daynumber)and a.classes<>'组合'
update @temp1 set nowin=a.nownum  from pro_ioput a,@temp1 b where a.pronum =b.pronum and a.type=1
update @temp1 set nowout =a.nownum from pro_ioput a,@temp1 b where a.pronum = b.pronum and a.type=2
return 
END