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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:42:20+00:00 2026-06-15T19:42:20+00:00

Oracle 11g How can I write query to get desired results? Specifically, How do

  • 0

Oracle 11g
How can I write query to get desired results? Specifically, How do I join to the most recent records in the REQUIREMENTS table?

Selection Criteria:
Most recent detail and most recent requirements

 with 
 detail as (
 select 'TAXI' code, '4920' numb, 1990 dstart, 'BLUE' taxi_name from dual union all
 select 'TAXI' code, '4920' numb, 2000 dstart, 'PINK' taxi_name from dual union all
 select 'TAXI' code, '4920' numb, 2008 dstart, 'CYAN' taxi_name from dual),

 requirement  as (
select 'TAXI' code, '4920' numb,  2 seqno, 2000 rstart,  25,min_age,'CDL',permit from dual union all
select 'TAXI' code, '4920' numb,  4 seqno, 2000 rstart, 27 min_age, 'CAR' permit from dual union all
select 'TAXI' code, '4920' numb,  6 seqno, 2000 rstart, 29 min_age, 'HAZ' permit from dual union all
select 'TAXI' code, '4920' numb,  2 seqno, 2007 rstart, 24 min_age, 'CDL' permit from dual union all
select 'TAXI' code, '4920' numb,  4 seqno, 2007 rstart, 26 min_age, 'VAN' permit from dual union all
select 'TAXI' code, '4920' numb,  6 seqno, 2007 rstart, 28 min_age, 'HAZ' permit from dual

)

select code,numb,taxi_name, dstart, ranking from (
select code, numb, taxi_name,dstart, rank() over (partition by code, numb 
                                            order by dstart desc ) ranking
from detail)
where ranking =1

Yields

CODE NUMB  NAME  YEAR    
---- ---- -----  ------- 
TAXI 4920 CYAN   2008 


DESIRED OUTPUT
--------------------------
 code numb name        dstart     sqno    rstart   min_age permit
 TAXI 4920 CYAN       2008       2         2007    24      CDL
 TAXI 4920 CYAN       2008       4         2007    26      VAN
 TAXI 4920 CYAN       2008       6         2007    28      HAZ
  • 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-15T19:42:21+00:00Added an answer on June 15, 2026 at 7:42 pm

    Well, you essentially have the idea. You just need to apply it to two tables:

    select code,numb,taxi_name, dstart, ranking
    from (select code, numb, taxi_name,dstart,
                 rank() over (partition by code, numb order by dstart desc) as ranking
          from detail
         ) d join
         (select r.*,
                 rank() over (partition by code, numb order by rstart desc) as ranking
          from requirement
         ) r
         on d.code = r.code and
            d.ranking = 1 and
            r.ranking = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PL/SQL on Oracle 11g How can I write query to return desired result?
Oracle 11g PERSON table contains both seller and buyer ID. How can I get
My Question: How do you query an 11g Oracle database to get a description
I was wondering which tool in ORACLE 11g (their latest DBMS) can be used
I work with Oracle 11g. I have one table: create table test (one number(2),
I want to write a query to get the names of tables of a
How can I make a package that returns results in table format when passed
Working with Oracle 11g here. I'm trying to figure out how to write a
In oracle 11g, how can I convert character data in a column that falls
I am using oracle 11g. I write code to connect oracle database with java

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.