sql - Combine 2 rows to the same column -


hey query right

alter procedure [ssrs].[volumecustomers] @userid int    select      casetypename,     count(caseno) casecount,     'open' indicator  orders.apcase ac (nolock)     join orders.casetype ct (nolock) on ct.casetypeid = ac.casetypeid     join workflow.workflowhistory wh (nolock) on wh.entityid = ac.caseid , tableid = dbo.gettableid('apcase', 'orders') , wh.active = 1     inner join workflow.workflowstep ws (nolock) on ws.workflowstepid = wh.workflowstepid , ws.nextstepid null (ac.active =1 , ac.createddate >= dateadd(day,-7,getdate()) , ac.createddate < getdate())  group casetypename  union select      casetypename,     count(caseno) casecount,     'closed' indicator  orders.apcase ac (nolock)     join orders.casetype ct (nolock) on ct.casetypeid = ac.casetypeid     join workflow.workflowhistory wh (nolock) on wh.entityid = ac.caseid , tableid = dbo.gettableid('apcase', 'orders') , wh.active = 1     join workflow.workflowstep ws (nolock) on ws.workflowstepid = wh.workflowstepid , ws.nextstepid not null (ac.active =1 , ac.createddate >= dateadd(day,-7,getdate()) , ac.createddate < getdate())   group casetypename  order casecount desc 

and out put is

cytogenetics    2   cytogenetics    1   open flow tech   1   flow tech   1   open surgical    1   surgical             1  open 

but want cytogenetics, flow tech, , surgical appear on same row example:

cytogenetics    2   1   open flow tech            1             1    open surgical             1       1        open 

how edit query reflect this?

does work?

select a.*, b.casecount, b.indicator   (<first part of union in question>) inner join        (<second part of union in question>) b on a.casetypename = b.casetypename 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -