0

ちょっと私の問題はこのようになります、それは他の人にも役立つかもしれません私はinstance_idを持つ注文を持っています. チケットは、オープン クローズまたは進行中など、さまざまな段階にある可能性があります。注文に 4 つのチケットがあり、チケットが 4 つ以下の多くの注文があるとします。1 つのタイプのチケットのすべてのオープン チケットを見つけ、その service_instance_id を取得し、それに対応します。その注文のために開いている他のチケットを見つけます。

次のクエリを使用して、私はそれを見つけることができますが、それはすべて互いに下に来ます。特定の注文に対して4つのチケット情報すべてを1行に表示したいのですが、特定のチケットがその注文に対してクローズされている場合、表示された

 select a.sr_num Acceptance_TT, a.act_open_dt Acceptance_Date, e.login Acceptance_Owner , c.sr_area, c.sr_num, c.act_open_dt, d.login, case when c.sr_stat_id in ('Closed','Cancelled') then '-' else c.sr_stat_id end TT_Status
    from 
    siebel.s_srv_req a -- GOC TT
    ,siebel.s_order_item b -- ServiceInstanceID
    ,siebel.s_srv_req c -- Project Management
    ,siebel.s_user d -- Owner
    ,siebel.s_user e -- GOC Owner
    where 
    a.sr_area = 'GOC Acceptance' and a.sr_num='20130601-3-28'
    and a.sr_stat_id in ('Open - GOC')
    and a.x_service_instance_id = b.row_id
    and c.x_service_instance_id = b.row_id
    and c.sr_area = 'Project Management'
    --and c.sr_stat_id not in ('Closed','Cancelled')
    and c.owner_emp_id = d.row_id
    and a.owner_emp_id = e.row_id  PM 5:39 
    UNION all
    select a.sr_num Acceptance_TT, a.act_open_dt Acceptance_Date, e.login Acceptance_Owner, c.sr_area, c.sr_num, c.act_open_dt, d.login, case when c.sr_stat_id in ('Closed','Cancelled') then '-' else c.sr_stat_id end TT_Status
    from 
    siebel.s_srv_req a -- GOC TT
    ,siebel.s_order_item b -- ServiceInstanceID
    ,siebel.s_srv_req c -- Provisioning
    ,siebel.s_user d -- Owner
    ,siebel.s_user e -- GOC Owner
    where 
    a.sr_area = 'GOC Acceptance' and a.sr_num='20130601-3-28'
    and a.sr_stat_id in ('Open - GOC')
    and a.x_service_instance_id = b.row_id
    and c.x_service_instance_id = b.row_id
    and c.sr_area = 'Provisioning'
    --and c.sr_stat_id not in ('Closed','Cancelled')
    and c.owner_emp_id = d.row_id
    and a.owner_emp_id = e.row_id  PM 5:39 
    UNION all
    select a.sr_num Acceptance_TT, a.act_open_dt Acceptance_Date, e.login Acceptance_Owner, c.sr_area, c.sr_num, c.act_open_dt, d.login, case when c.sr_stat_id in ('Closed','Cancelled') then '-' else c.sr_stat_id end TT_Status
    from 
    siebel.s_srv_req a -- GOC TT
    ,siebel.s_order_item b -- ServiceInstanceID
    ,siebel.s_srv_req c -- CE Implementation
    ,siebel.s_user d -- Owner
    ,siebel.s_user e -- GOC Owner
    where 
    a.sr_area = 'GOC Acceptance' and a.sr_num='20130601-3-28'
    and a.sr_stat_id in ('Open - GOC')
    and a.x_service_instance_id = b.row_id
    and c.x_service_instance_id = b.row_id
    and c.sr_area = 'CE Implementation'
    --and c.sr_stat_id not in ('Closed','Cancelled')
    and c.owner_emp_id = d.row_id
    and a.owner_emp_id = e.row_id  
4

1 に答える 1

1

これを試して結果を共有してください。テストする構成がありません

with tab as (
    select a.sr_num Acceptance_TT, 
           a.act_open_dt Acceptance_Date, 
           e.login Acceptance_Owner, 
           c.sr_area, 
           c.sr_num, 
           c.act_open_dt, 
           d.login, 
           case when c.sr_stat_id in ('Closed','Cancelled') then '-' else c.sr_stat_id end TT_Status
    from 
    siebel.s_srv_req a -- GOC TT
    ,siebel.s_order_item b -- ServiceInstanceID
    ,siebel.s_srv_req c -- CE Implementation
    ,siebel.s_user d -- Owner
    ,siebel.s_user e -- GOC Owner
    where 
    a.sr_area = 'GOC Acceptance' and a.sr_num='20130601-3-28'
    and a.sr_stat_id in ('Open - GOC')
    and a.x_service_instance_id = b.row_id
    and c.x_service_instance_id = b.row_id
    and c.sr_area in ('CE Implementation', 'Project Management', 'Provisioning')
    and c.owner_emp_id = d.row_id
    and a.owner_emp_id = e.row_id
    )
 select * 
   from tab 
  pivot (min(TT_Status) as TT_Status for (sr_area) in ('CE Implementation' as CE, 'Project Management' as PM, 'Provisioning' as PRO))
于 2014-01-27T04:32:14.370 に答える