with temp_data as(select shareID,carID from dbo.che_ShareCar)
select car_info.CARID, car_info.CAR_MARK , case when min(shareID) is null then 0 else COUNT(CAR_INFO.CARID) end as sharecount
from dbo.CAR_INFO left join temp_data on CAR_INFO.CARID=temp_data.carID
where COMPANYID=2 --and shareID is not null
group by CAR_INFO.CARID,CAR_INFO.CAR_MARK