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

  • SEARCH
  • Home
  • 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 9180611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:06:06+00:00 2026-06-17T18:06:06+00:00

I’m having trouble with a particular Oracle query. I’m trying to write a query

  • 0

I’m having trouble with a particular Oracle query. I’m trying to write a query to pull the following data.

• “How many students who were previously suspended for reason of “bad behaviour” have since been re-assessed AND the number over 12 years old and under 12 years old”

Three tables I believe I need to work with: person status history (contains REASON, SUSPEND_TO_DATE), person_visit (contains fields like VISIT_DATE) and person (contains fields such as PERSON_ID and BIRTH_DATE).

(PERSON_ID is common across all tables.)

Here was my amateur attempt, I’m still not fully sure of the use of joins & how to work out the over 12/under 12 using only the BIRTH_DATE information is another issue.

select count (*) from person_status_history 
inner join person_visit on person_status_history.person_id=person_visit.person_id
inner join person on person_visit.person_id=person.person_id
where person_status_history.reason_code = 85 and person_visit.reasses_appoint_no is not null and person.birth_date < '23-JAN-2000';

In basic pseudo-code I suppose what I need to develop is (very rough!):

SELECT * PERSON_ID WHERE SUSPEND_TO_DATE is NOT NULL AND REASON = “85” AND VISIT_DATE > SUSPEND_TO_DATE and count the number >12 AND < 12.

Can anyone advise?

  • 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-06-17T18:06:07+00:00Added an answer on June 17, 2026 at 6:06 pm

    Thinking about this as: “For which students does there exist a suspension for which there is a subsequent visit” …

    select case when p.date_of_birth < current_date - interval '12 year'
           then '< 12'
           else '12+'
           end age_bracket,
           count (*)
    from   person p
    where  exists (
             select null
             from   person_status_history psh
             where  psh.person_id   = p.person_id and
                    psh.reason_code = 85          and
                    exists (
                      select null
                      from   person_visit pv
                      where  pv.person_id          = psh.person_id and
                             pv.reasses_appoint_no is not null     and
                             pv.visit_date         > psh.suspend_to_date)
    group by case when p.date_of_birth < current_date - interval '12 year'
             then '< 12'
             else '12+'
             end
    

    Not tested for syntax errors etc though.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group

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.