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 3846246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:22:06+00:00 2026-05-19T16:22:06+00:00

I’m writing a View in Oracle 9 database, and I’m stumped. What I’m trying

  • 0

I’m writing a View in Oracle 9 database, and I’m stumped. What I’m trying to solve is this: A_WPD_ADDRESS_HISTORY contains a FK called WPD_PLAN_CHECK_S, and this view holds multiple addresses for this one FK. I’m trying to get the most recent address per WPD_PLAN_CHECK_S (FK). You would use the FIRST_INSERTED column, which is the date/time that row was first inserted and call the aggregate function MAX() on it, but that’s all I know at this moment, and thus I’m stumped.

Below are the two main views I think are needed to understand this problem. The other tables/views are irrelevant to this problem for what I”m currently trying to solve.

Below: Main View that I’m trying to retrieve the most recent address record on.

SELECT
  awa.wpd_address_history_s,
  wpc.wpd_plan_check_s,
  wpc.pcis_display,
  awa.street_num,
  awa.street_frac,
  awa.street_prefix,
  awa.street_name,
  awa.street_type_l_s,
  awa.street_suffix,
  awa.street_unit_l_s,
  awa.street_unit_num,
  awa.cross_streets,
  awa.city,
  awa.state,
  awa.state_l_s,
  awa.zip,
  awa.zip_ext,
  awa.zip_with_ext,
  wf.ind_id,
  wpc.wpd_status_l_s,
  wsl.wpd_status_desc,
  awa.location as LOCATION, 
  wc.contact_name     
FROM
  wpd_plan_check wpc
  LEFT OUTER JOIN a_wpd_address_history awa ON wpc.wpd_plan_check_s = awa.wpd_plan_check_s
  LEFT OUTER JOIN wpd_contact  wc   ON wpc.wpd_plan_check_s = wc.wpd_plan_check_s
  LEFT OUTER JOIN wpd_facility wf   ON wpc.wpd_plan_check_s = wf.wpd_plan_check_s
  LEFT OUTER JOIN wpd_status_l wsl  ON wpc.wpd_status_l_s = wsl.wpd_status_l_s
  LEFT OUTER JOIN street_type_l stl ON awa.street_type_l_s = stl.street_type_l_s
  LEFT OUTER JOIN street_unit_l sul ON awa.street_unit_l_s = sul.street_unit_l_s

—

Below: Address History view that I”m pulling from

   CREATE OR REPLACE FORCE VIEW a_wpd_address_history (wpd_address_history_s,
                                                        wpd_plan_check_s,
                                                        street_num,
                                                        street_frac,
                                                        street_prefix,
                                                        street_name,
                                                        street_type_l_s,
                                                        street_suffix,
                                                        street_unit_l_s,
                                                        street_unit_num,
                                                        cross_streets,
                                                        city,
                                                        state_l_s,
                                                        state,
                                                        zip,
                                                        zip_ext,
                                                        zip_with_ext,
                                                        LOCATION,
                                                        apn_num,
                                                        river_desc,
                                                        first_inserted
                                                       )
    AS
       SELECT DISTINCT a.wpd_address_history_s, a.wpd_plan_check_s, a.street_num,
                       a.street_frac, a.street_prefix, a.street_name,
                       a.street_type_l_s, a.street_suffix, a.street_unit_l_s,
                       a.street_unit_num, a.cross_streets, a.city, a.state_l_s,
                       s.state, a.zip, a.zip_ext,
                          a.zip
                       || NVL2 (a.zip_ext, '-' || a.zip_ext, '') AS zip_with_ext,
                          LTRIM (a.street_num || ' ')
                       || LTRIM (NVL (a.street_frac, ' ') || ' ')
                       || LTRIM (NVL (a.street_prefix, ' ') || ' ')
                       || LTRIM (NVL (a.street_name, ' ') || ' ')
                       || LTRIM (NVL (stl.street_type_desc, ' ') || ' ')
                       || LTRIM (NVL (a.street_suffix, ' ') || ' ') AS LOCATION,
                       a.apn_num, r.river_desc, first_inserted
                  FROM wpd_address_history a LEFT OUTER JOIN street_type_l stl
                       ON a.street_type_l_s = stl.street_type_l_s
                       LEFT OUTER JOIN street_unit_l sul
                       ON a.street_unit_l_s = sul.street_unit_l_s
                       LEFT OUTER JOIN state_l s ON a.state_l_s = s.state_l_s
                       LEFT OUTER JOIN river_l r ON a.river_l_s = r.river_l_s
  • 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-19T16:22:07+00:00Added an answer on May 19, 2026 at 4:22 pm

    The most common solution would be something like

    SELECT
      awa.wpd_address_history_s,
      wpc.wpd_plan_check_s,
      wpc.pcis_display,
      awa.street_num,
      awa.street_frac,
      awa.street_prefix,
      awa.street_name,
      awa.street_type_l_s,
      awa.street_suffix,
      awa.street_unit_l_s,
      awa.street_unit_num,
      awa.cross_streets,
      awa.city,
      awa.state,
      awa.state_l_s,
      awa.zip,
      awa.zip_ext,
      awa.zip_with_ext,
      wf.ind_id,
      wpc.wpd_status_l_s,
      wsl.wpd_status_desc,
      awa.location as LOCATION, 
      wc.contact_name     
    FROM
      wpd_plan_check wpc
      LEFT OUTER JOIN a_wpd_address_history awa ON wpc.wpd_plan_check_s = awa.wpd_plan_check_s
      LEFT OUTER JOIN wpd_contact  wc   ON wpc.wpd_plan_check_s = wc.wpd_plan_check_s
      LEFT OUTER JOIN wpd_facility wf   ON wpc.wpd_plan_check_s = wf.wpd_plan_check_s
      LEFT OUTER JOIN wpd_status_l wsl  ON wpc.wpd_status_l_s = wsl.wpd_status_l_s
      LEFT OUTER JOIN street_type_l stl ON awa.street_type_l_s = stl.street_type_l_s
      LEFT OUTER JOIN street_unit_l sul ON awa.street_unit_l_s = sul.street_unit_l_s
    WHERE awa.first_inserted = (SELECT MAX(awa2.first_inserted)
                                 FROM a_wpd_address_history awa2
                                WHERE awa.wpd_plan_check_s = awa2.wpd_plan_check_s)
    

    However it’s likely more efficient to do something like this with analytic functions so that you only have to hit the view once.

    WITH awa AS (
      SELECT awa_inner.*, 
             RANK() OVER (PARTITION BY wpd_plan_check_s ORDER BY first_inserted DESC) rnk
        FROM a_wpd_address_history awa_inner
    )
    SELECT
      awa.wpd_address_history_s,
      wpc.wpd_plan_check_s,
      wpc.pcis_display,
      awa.street_num,
      awa.street_frac,
      awa.street_prefix,
      awa.street_name,
      awa.street_type_l_s,
      awa.street_suffix,
      awa.street_unit_l_s,
      awa.street_unit_num,
      awa.cross_streets,
      awa.city,
      awa.state,
      awa.state_l_s,
      awa.zip,
      awa.zip_ext,
      awa.zip_with_ext,
      wf.ind_id,
      wpc.wpd_status_l_s,
      wsl.wpd_status_desc,
      awa.location as LOCATION, 
      wc.contact_name     
    FROM
      wpd_plan_check wpc
      LEFT OUTER JOIN awa               ON wpc.wpd_plan_check_s = awa.wpd_plan_check_s
      LEFT OUTER JOIN wpd_contact  wc   ON wpc.wpd_plan_check_s = wc.wpd_plan_check_s
      LEFT OUTER JOIN wpd_facility wf   ON wpc.wpd_plan_check_s = wf.wpd_plan_check_s
      LEFT OUTER JOIN wpd_status_l wsl  ON wpc.wpd_status_l_s = wsl.wpd_status_l_s
      LEFT OUTER JOIN street_type_l stl ON awa.street_type_l_s = stl.street_type_l_s
      LEFT OUTER JOIN street_unit_l sul ON awa.street_unit_l_s = sul.street_unit_l_s
    WHERE awa.rnk = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.