Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to rewrite this query without sub query please help me

$
0
0

Hello All Good Evening,

Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways

please help me



select planno, status1, count(*) Counts from
(
select a.ValetNO PlanNo  ,
case 
     when JoinCode in ('00', '01', '02') then 'Actcess'
     when JoinCode in ('20', '21', '22', '23','38', '39') then
     'Secured' else 'Other' end Status1 ---, COUNT (*)
     
   from  dbo.ppt a(NOLOCK)  left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO  = b.ValetNO

--group by a.ValetNO
)
  a group by planno, status1
order by 2

Thank you in Advance
Milan


Viewing all articles
Browse latest Browse all 23857

Trending Articles