sql2005 select d.drivername,
(select mpCount from dbo.GetDriverMileage(d.id,'','')) as a ,
(select kmSum from dbo.GetDriverMileage(d.id,'','')) as b ,c.carnum,ad.initdate
from dbo.t_b_Driver d
right join dbo.t_e_AvailableDriver ad on ad.DriverID=d.ID
left join dbo.t_e_AvailableCar ac on ad.usecarid=ac.id
left join dbo.t_b_Car c on c.id=ac.carid
where 1=1 group by d.drivername,c.carnum,ad.initdate