请帮忙把下面的存储过程改写成一个用户自定义函数输出,谢谢!
create table Cost(car char(2),Type varchar(20),cost money,
starttime datetime ,endtime datetime )
insert into cost
select 'A_ ' , '管理费 ' ,100, '2007-05-29 ', '2007-06-08 '
union all select 'A_ ' , '保险费 ' ,1000, '2007-06-01 ', '2008-06-01 '
union all select 'B_ ' , '管理费 ' ,300, '2007-04-22 ', '2007-08-22 '
create table sjwork(sjname char(8),car char(2),riqi datetime)
insert into sjwork --truncate table sjwork
select 'A ' , 'A_ ' , '2007-06-01 '
union all select 'A ', 'B_ ', '2007-06-05 '
union all select 'A ', 'A_ ', '2007-06-12 '
union all select 'B ', 'B_ ' , '2007-06-01 '
union all select 'B ', 'A_ ' , '2007-06-05 '
union all select 'B ' , 'B_ ' , '2007-06-12 '
union all select 'C ' , 'C_ ', '2007-05-22 '
create table sj
(sjname char(8) not null)
insert into sj
select 'A '
union all select 'B '
union all select 'C '
----------------------------------------------------///
create alter proc carcost @starttime datetime,@endtime datetime,@sjname char(8),@cost money output as
begin
select car,type,
(case when @starttime > =sta