- alter PROCEDURE [dbo].[web_GetAllFriendInfo]
- @AdvisorId uniqueidentifier,
- @PageSize int,
- @PageIndex int,
- @Total int output
- AS
- create table #tmp
- (
- rowid int,
- AdvisorId uniqueidentifier,
- FriendId uniqueidentifier
- )
- insert into #tmp select ROW_NUMBER() over (order by UpdateDate desc) as rowid,AdvisorId,FriendId
- from AdvisorDb.dbo.Friends where AdvisorId=@AdvisorId
- select a.rowid,a.AdvisorId, b.FriendId,b.email,b.advisorname,b.status,b.gender,
- (case when b.risktype is null then N'未知' else b.risktype end) as risktype ,
- b.avatar,
- (case when b.avatarwidth is null then 0 else b.avatarwidth end) as avatarwidth,
- (case when b.avatarheight is null then 0 else b.avatarheight end) as avatarheight
- from #tmp a left join
- (select pa.*,avatar,avatarwidth,avatarheight from (select AdvisorId as FriendId ,email,advisorname,status,gender,risktype from AdvisorDb.dbo.Advisors t left join AdvisorDb.dbo.RiskResult p on t.AdvisorId=p.AccountId) pa
- left join (select email ,avatar,avatarwidth,avatarheight from Discuz.dbo.dnt_users da,Discuz.dbo.dnt_userfields db where da.uid=db.uid) pf
- on pa.email collate SQL_Latin1_General_CP1_CI_AS=pf.email) b
- on a.FriendId=b.FriendId
- where rowid>@PageSize*(@PageIndex-1) and rowid<=@PageSize*@PageIndex
- order by rowid
- drop table #tmp
- declare @total int
- exec [web_GetAllFriendInfo] '3AC8F780-365C-48AD-A1A1-03F4913CBA10',20,1,@total output