根据一列去除查询中的重复数据

select b.industry, b.loginname,a.enddate,a.verify, a.userid,a.position,b.companyname
from c_job as a left join u_userinfo as b on a.UserID=b.UserID 
where  a.id in (select max(id) from c_job group by UserID)
and a.userid in (SELECT DISTINCT b.UserID FROM dbo.U_UserInfo
INNER JOIN dbo.C_Job ON b.UserID = a.UserID)

你可能感兴趣的:(查询)