Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:57:51+00:00 2026-05-30T04:57:51+00:00

Okay, first off I will attempt to explain what I’m trying to do. I

  • 0

Okay, first off I will attempt to explain what I’m trying to do. I am trying to build a report that returns all assessments assigned to a client. Each assessment should have a corresponding event, and vice versa (unfortunately there is no token passed between the two so I have to determine the correct event based on dates). However, the event is sometimes missing, or the assessment is sometimes missing. I wish to capture all of these so that I can report where there are missing assessments or events and have them fixed. In it’s most simple form, this is what I would expect the report to look like. However, there are a few other conditions, such as returning a particular type of assessment and a particular type of event.

ID  Assessment   Event
1   A1           B1
2   A2   
3                B3      

I currently have 2 queries written that show me all assessments with their corresponding events (if present), and all events with their corresponding assessments (if present). They both seem to work well, but I would really like to join the two queries (ID would be common in both queries). I’ve tried doing this myself, but it never quite works, so I’m hoping if I post both of my working queries, someone may be able to assist!

This brings back assessments with their corresponding event (where present).

 SELECT 
  "CLIENTID",
 "Name",
   "ASSESSMENT_ID",
 "Assessment_Start", 
 "Assessment_End",
  "Days open",
 "Authorised",
  "Worker",
  "Event_ID",
  "Event_Start"
 FROM 
 (SELECT 
 OAS.ASM_SUBJECT_ID as "CLIENTID",
   nvl(olm_bo.get_name(OAS.ASM_SUBJECT_ID,OAS.ASM_SUBJECT_IND),'') as "Name",
 OAS.ASM_ID as ASSESSMENT_ID,
 olm_bo.working_days(OAS.ASM_START_DATE, OAS.ASM_END_DATE) -1 as "Days open",
 OAS.ASM_AUTH_DATETIME as "Authorised",
 OAS.ASM_START_DATE as "Assessment_Start", 
 OAS.ASM_END_DATE as "Assessment_End",
 nvl(olm_bo.get_ref_desc(OAS.ASM_OUTCOME,'ASM_OUTCOME'),'') as "Outcome",
 nvl(olm_bo.get_org_name(ORE.RES_PARTY_OUN_ID),'') as "Team",
 initcap(nvl(olm_bo.get_per_name(ORE.RES_PARTY_ID),'')) as "Worker",
 OSE.SEV_ID as "Event_ID",
 to_char(trunc(OSE.SEV_ACTUAL_DATE),'DD/MM/YYYY') as "Event_Start",
 OSE.SEV_OUTCOME_DATE as "Event_End",
 nvl(decode(OSE.SEV_CLASS,'CPINVEST',olm_bo.get_ref_desc     (OSE.SEV_REASON_CODE,'CP_JUSTIFICATION'),olm_bo.get_ref_desc     (OSE.SEV_REASON_CODE,'REASON_CODE')),'') as "Event Outcome",
 row_number() over(PARTITION BY  OAS.ASM_ID                   
 ORDER BY 
 abs(OAS.ASM_START_DATE -  OSE.SEV_ACTUAL_DATE))as "Row Number"
 FROM O_ASSESSMENTS OAS      
 INNER JOIN O_RESPONSIBILITIES ORE ON OAS.ASM_ID = ORE.RES_REC_ID
 AND nvl(olm_bo.get_org_name(ORE.RES_PARTY_OUN_ID),'') = '#Team#' 
 LEFT JOIN O_SERVICE_EVENTS OSE ON OAS.ASM_SUBJECT_ID = OSE.SEV_SUBJECT_ID 
 AND            
 OSE.SEV_CODE IN ('INI') 
 AND             
 ROUND(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE,0) >= -7
 AND
 ROUND(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE,0) <= 7
 Where OAS.ASM_QSA_ID  IN ('A1','A2')
 AND
    nvl(olm_bo.get_ref_desc(OAS.ASM_OUTCOME,'ASM_OUTCOME'),'NULL')  NOT IN       ( 'Abandon'  )
 AND
    (
     OAS.ASM_END_DATE  Is Null  
     OR
     OAS.ASM_AUTH_DATETIME  Is Null  
    )
 ) WHERE "Row Number" = 1

This brings back events with their corresponding assessment (where present).

 SELECT 
  "CLIENTID",
 "Name",
   "Event_ID",
 "Event_Start", 
 "Event_End",
  "Days_open",
  "Worker",
 "Team",
  "Assessment_ID",
  "Assessment_Start",
 "Assessment_End",
 FROM 
 (SELECT 
 OSE.SEV_SUBJECT_ID as "CLIENTID",
   nvl(olm_bo.get_name(OSE.SEV_SUBJECT_ID,OSE.SEV_SUBJECT_IND),'') as "Name",
 OAS.ASM_ID as  "Assessment_ID",
 olm_bo.working_days(OSE.SEV_ACTUAL_DATE, OSE.SEV_OUTCOME_DATE) -1 as "Days_open",
 OAS.ASM_START_DATE as "Assessment_Start", 
 OAS.ASM_END_DATE as "Assessment_End",
 olm_bo.get_org_name(OSE.SEV_OUN_SHORT_NAME) as "Team",
 olm_bo.get_event_worker(OSE.SEV_ID,'NAME') as "Worker",
 OSE.SEV_ID as "Event_ID",
 to_char(trunc(OSE.SEV_ACTUAL_DATE),'DD/MM/YYYY') as "Event_Start",
 OSE.SEV_OUTCOME_DATE as "Event_End",
 nvl(decode(OSE.SEV_CLASS,'CPINVEST',olm_bo.get_ref_desc     (OSE.SEV_REASON_CODE,'CP_JUSTIFICATION'),olm_bo.get_ref_desc(OSE.SEV_REASON_CODE,'REASON_CODE')),'') as "Event Outcome",
 row_number() over(PARTITION BY  OSE.SEV_SUBJECT_ID                   
 ORDER BY 
 abs(OAS.ASM_START_DATE -  OSE.SEV_ACTUAL_DATE))as "Row Number"
 FROM O_SERVICE_EVENTS OSE
 LEFT JOIN O_ASSESSMENTS OAS ON OAS.ASM_SUBJECT_ID = OSE.SEV_SUBJECT_ID AND nvl     (olm_bo.get_ref_desc(OAS.ASM_OUTCOME,'ASM_OUTCOME'),'NULL')  NOT IN  ( 'Abandon'  )
 AND
 OAS.ASM_QSA_ID  IN ('A1','A2')            
 AND             
 ROUND(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE,0) >= -7
 AND
 ROUND(OAS.ASM_START_DATE - OSE.SEV_ACTUAL_DATE,0) <= 7
 Where OSE.SEV_CODE IN ('INITASS') 
 AND
 olm_bo.get_org_name(OSE.SEV_OUN_SHORT_NAME) = '#Team#'
 AND
    (
     OSE.SEV_OUTCOME_DATE  Is Null  
    )
 ) WHERE "Row Number" = 1

There are also some catches with a joined report – events and assessments can have different teams or workers, so I’d probably need to define seperate event team and event workers from the assessment team and event worker. I did think that this could be achieved by doing an outer join, or by joining the assessments and the events to a seperate table which returns all clients with an assessment or an event, but as mentioned, the results never seemed to quite add up to the seperate queries. I think it could be something to do with the row number = 1 condition, this is there to assist with returning a corresponding assessment to an event or vice versa, but I think when trying to join the two, this might be causing some of the problems? Anyway, thanks for your time – I will continue to tinker and see if I can find a solution, but any tips or suggestions would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:57:53+00:00Added an answer on May 30, 2026 at 4:57 am

    Why don’t you union your 2 queries? If applicable, use union all which is much performer that union.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first, I can't stand Crystal! Okay, that's off my chest... Now, we have an
Okay, allow me to say first off that I am working on developing my
Okay I will first admit I don't know the proper terminology for all this
Okay, here's what I'm trying to do. First I'll explain the end result I'm
OKay first off this is really really similiar to the http://dribbble.com homepage. In the
First off I'm using Mac. Next, I need to execute this "file.sh" we will
I've been trying to setup my first rails app--I'm okay at stumbling around on
Okay so first off, Im pretty new to programming, Ive only read a bit
Okay first of all, I admit I took elements from this question here: How
Okay so basically I'm trying to do a depth-first search for a mini-peg solitaire

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.