关于一个sql查询数据,数据某列有重复,其他列无重复,取出重复列的问题。
贴sql语句。
alter proc proc_IntegralMng(@page int,@pagesize int)
as
select Integral.ID,PhoneUserInfo.RealUserName,Integral.Integral,IntegralStatus.LoginNumber,
IntegralStatus.CommentNumber,IntegralStatus.ShareNumber,IntegralStatus.PublishNumber,IntegralStatus.StatusTime
from Integral
left join IntegralStatus on Integral.UserID = IntegralStatus.LoginID
left join PhoneUserInfo on PhoneUserInfo.Id = Integral.UserID
where IntegralStatus.LoginID <> 0 and PhoneUserInfo.RealUserName is not null and
PhoneUserInfo.RealUserName <> '' order by Integral.integral desc,StatusTime desc
where PhoneUserInfo.RealUserName+IntegralStatus.StatusTime not in
(select top(@pagesize * (@page-1)) PhoneUserInfo.RealUserName+IntegralStatus.StatusTime from Integral
left join IntegralStatus on Integral.UserID = IntegralStatus.LoginID
left join PhoneUserInfo on PhoneUserInfo.Id = Integral.UserID
where IntegralStatus.LoginID <> 0 and PhoneUserInfo.RealUserName is not null and
PhoneUserInfo.RealUserName <> '' order by Integral.integral desc,StatusTime desc)
and IntegralStatus.LoginID <> 0 and PhoneUserInfo.RealUserName is not null and
PhoneUserInfo.RealUserName <> '' order by Integral.integral desc,StatusTime desc