Select rd.nm_last , rd.userid, count(rd.userid) as Ct
From mabresults mb
inner join W_Ptproc PP on pp.pat_exam_id=mb.xm_id
inner join remote.dbo.w_rads RD on RD.userid=pp.prov_id
Where mb.sts_cd = '10'
and pp.proc_start_dttm between '2008-11-01' and '2009-10-31'
and mb.bio = '0'
group by rd.nm_last, rd.userid order by rd.nm_last
Do more with
Select rd.nm_last , rd.userid, count(rd.userid) as Ct, SUM(rd.userid) AS sumOfUserid
From mabresults mb
inner join W_Ptproc PP on pp.pat_exam_id=mb.xm_id
inner join remote.dbo.w_rads RD on RD.userid=pp.prov_id
Where mb.sts_cd = '10'
and pp.proc_start_dttm between '2008-11-01' and '2009-10-31'
and mb.bio = '0'
group by rd.nm_last, rd.userid
order by rd.nm_last, rd.userid
Select rd.nm_last ,
rd.userid,
count(rd.userid) over (partition by rd.nm_last, rd.userid) as Ct,
count(rd.userid) over (partition by 0) as totalCT
From mabresults mb
inner join W_Ptproc PP on pp.pat_exam_id=mb.xm_id
inner join remote.dbo.w_rads RD on RD.userid=pp.prov_id
Where mb.sts_cd = '10'
and pp.proc_start_dttm between '2008-11-01' and '2009-10-31'
and mb.bio = '0'
order by rd.nm_last
Select distinct
rd.nm_last ,
rd.userid,
count(rd.userid) over (partition by rd.nm_last, rd.userid) as Ct,
count(rd.userid) over (partition by 0) as totalCT
From mabresults mb
inner join W_Ptproc PP on pp.pat_exam_id=mb.xm_id
inner join remote.dbo.w_rads RD on RD.userid=pp.prov_id
Where mb.sts_cd = '10'
and pp.proc_start_dttm between '2008-11-01' and '2009-10-31'
and mb.bio = '0'
order by rd.nm_last
Premium Content
You need an Expert Office subscription to comment.Start Free Trial