Im trying to build a sql question that will only return 1 row per project. Every project has a nr of task_id that i’m later on gonna update with a block in pl/sql, but to be able to do that i need the task_id from every name “Name of the task” that is gonna be updated with a new status.

here is my sql. Would really apreciate if someone has any helpful thoughts on this one.

SELECT 
  *
FROM (
  SELECT 
    a.responsible AS "Ansvarig",
    a.name,
    a.project_id || '.' || a.sub_project_id || '.' || a.activity_no AS "Kortnamn",
    a.status,
    (ifsapp.SUB_PROJECT_API.Get_Description((a`your text`.PROJECT_ID), (a.SUB_PROJECT_ID))) AS "Beskrivning",
    a.task_id "uppgiftsnr"

  
  FROM ifsapp.ACTIVITY_TASK_EXT2 a
  WHERE 
    a.project_id = '7700'
    AND a.activity_no = '010'
    AND a.sub_project_id LIKE '400703783'
    --AND a.completed_date > '2023-01-01'
    AND a.status IN (0, 1)
    AND a.project_id IN (
      SELECT project_id
      FROM ifsapp.activity b
      WHERE b.objstate = 'Released'
      AND a.activity_no = b.activity_no
    )
) PIVOT (
  max(status)

  FOR name IN (
     '1.01.1 - Platsbesök Bokad & DK Signal 1' as "platsbesokbokad",
     '1.01.2 - Platsbesök' as "Platsbesok",
     '1.02.1 - Slot-Begäran Skickad' as "slotbegaranskickad",
     '1.02.2 - Slot-Begäran Godkänd' as "slotbegarangodkand",
     '1.03.1 - FBL & DK Signal 2' as "fbldksignal",
     '1.04.1 - GVB' as "gvb",
     '1.05.1 - Mängdning' as "mangdning",
     '1.06.1 - AMP' as "amp",
     '1.07.1 - Arbetshandlingar Skapade' as "arbetshandlingarskapade",
     '1.07.2 - Arbetshandlingar Delade' as "arbetshandlingardelade",
     '1.08.1 - Materiel Beställt' as "materialbesallt",
     '1.08.2 - Materiel Levererat' as "materiallevererat"
  )
)





New contributor

viktor olofsson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Khám phá các thẻ bài đăng