筛选出某个用户的各个baby的最新记录
select a.Id,a.UserId,a.BabyId,a.BabyName,a.CreateTime from [Hmeshop_BabyInfo] as a inner join(select UserId,BabyId,MAX(CreateTime) CreateTime from [Hmeshop_BabyInfo] where UserId=26912
group by userId,BabyId) as b on a.UserId=b.UserId and a.CreateTime=b.CreateTime and a.BabyId=b.BabyId where a.UserId=26912
查询结果如下: