select * from dbo.Vehicle_Maintain_Details A inner join ( select MaintainType as tempTypeName,count(ID) as num from dbo.Vehicle_Maintain_Details group by MaintainType) B on A.MaintainType=B.tempTypeName