怎样写工资核算表的SQL?
create   table   工资表 
 ( 
 客户姓名   varchar(50), 
 车型   varchar(50), 
 合同编号      varchar(50), 
 修理内容      varchar(100), 
 修理费用   decimal(13,2), 
 派工日期      datetime 
 ) 
 insert   into   工资表   select    'aaa ', 'a车型 ', 'htzz-1 ', '切割车厢 ',2000, '2007-7-1 ' 
 insert   into   工资表   select    'aaa ', 'a车型 ', 'htzz-1 ', '焊合车厢 ',1500, '2007-7-1 ' 
 insert   into   工资表   select    'bbb ', 'b车型 ', 'htzz-2 ', '铆接车厢 ',1000, '2007-7-1 ' 
 insert   into   工资表   select    'bbb ', 'b车型 ', 'htzz-2 ', '连接车厢 ',2000, '2007-7-1 ' 
 /* 
 使用SQL产生以下工资核算表 
 客户姓名         车型            合同编号                                    工时费用                                                                     合计                     派工日期 
 aaa                     a车型            htzz-1         (切割车厢)2000元,(焊合车厢)1500元                        3500                     2007-7-1 
 bbb                     b车型            htzz-2         (铆接车厢)1000元,(连接车厢)2000元                        3000                     2007-1-1 
 */   
 drop   table   工资表
------解决方案--------------------create function dbo.uf_gets(@客户姓名 varchar(10)) 
 returns varchar(100) 
 as 
 begin 
 declare @s varchar(100) 
 set @s= ' ' 
 select @s=@s+ ',( '+修理内容+ ') '+rtrim(cast(修理费用 as int)) from 工资表 where 客户姓名=@客户姓名 
 set @s=stuff(@s,1,1, ' ') 
 return @s 
 end 
 go 
 select distinct 客户姓名,车型,合同编号,dbo.uf_gets(客户姓名) as  '工时费用 ',派工日期 from 工资表
------解决方案--------------------create table 工资表 
 ( 
 客户姓名 nvarchar(50), 
 车型 nvarchar(50), 
 合同编号  nvarchar(50), 
 修理内容  nvarchar(100), 
 修理费用 decimal(13,2), 
 派工日期  datetime 
 ) 
 insert into 工资表 select  'aaa ',N 'a车型 ', 'htzz-1 ',N '切割车厢 ',2000, '2007-7-1 ' 
 insert into 工资表 select  'aaa ',N 'a车型 ', 'htzz-1 ',N '焊合车厢 ',1500, '2007-7-1 ' 
 insert into 工资表 select  'bbb ',N 'b车型 ', 'htzz-2 ',N '铆接车厢 ',1000, '2007-7-1 ' 
 insert into 工资表 select  'bbb ',N 'b车型 ', 'htzz-2 ',N '连接车厢 ',2000, '2007-7-1 ' 
 /* 
 使用SQL产生以下工资核算表 
 客户姓名   车型    合同编号            工时费用                       合计       派工日期 
 aaa       a车型    htzz-1   (切割车厢)2000元,(焊合车厢)1500元        3500       2007-7-1 
 bbb       b车型    htzz-2   (铆接车厢)1000元,(连接车厢)2000元        3000       2007-1-1 
 */     
 create function f1(@id varchar(100)) 
 returns varchar(8000) 
 begin  
 	declare @str varchar(8000) 
 	set @str= ' ' 
 	select @str=@str+ '( '+修理内容+ ') '+rtrim(修理费用)+ '元 ' from 工资表 where 客户姓名=@id 
 	return @str 
 end     
 select 客户姓名,车型,合同编号,工时费用=dbo.f1(客户姓名),合计=sum(修理费用),派工日期=convert(char(10),派工日期,120)  
 from 工资表 
 group by 客户姓名,车型,合同编号,convert(char(10),派工