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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:18:39+00:00 2026-06-16T05:18:39+00:00

I would like to ask for your help for constructing a single ORACLE SQL

  • 0

I would like to ask for your help for constructing a single ORACLE SQL statement:

using job table as below

Object | Operation | Time  
A      | Move      | 12:01  
B      | Move      | 12:02  
C      | Pickup    | 12:03  
D      | Move      | 12:04  
B      | Pickup    | 12:05  

to get the result table as below.

Object | Operation | Time  | Cause  
A      | Move      | 12:01 | C  
B      | Move      | 12:02 | C  
D      | Move      | 12:04 | B 

This is to figure out which Pickup operation caused each Move operation.
“Cause” column must include Object of the pickup job record with smallest time right next to move operation.

I have some ideas as below but do not know how to.
-. It requires join statement between subquery for Move and subquery for Pickup
-. Subquery for Pickup must be partitioned by move record to be joined
-. Must select top record only from each partition of Pickup subquery

  • 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-16T05:18:40+00:00Added an answer on June 16, 2026 at 5:18 am

    This is my try:

    select  m.object, m.operation, m.time, 
      max(p.object) keep (dense_rank first order by p.time) cause,
      max(p.time) keep (dense_rank first order by p.time) cause_time
    from a m
    join a p on (p.time > m.time)
    where m.operation = 'Move'
    and p.operation = 'Pickup'
    group by m.object, m.operation, m.time;
    

    see SQLFiddle

    I’ve put column time as number, this does not have any importance as it is sortable.

    I’ve splitted the table in two, Moves and Pickups and the join is made on time, time of pickup being greater than time of move. (This type of join is not great on performance). Then I choose the pickup with smallest time(first clause, with order by p.time).

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

Sidebar

Related Questions

I am quite new about using Solr, but would like to ask your help.
I would like to ask your guidance on how to authenticate using email add/
Hello everybody :D I would like to ask for your help on this problem.
I use c#, linq and EF4 I would like ask your help. My question:
Hello I would like to ask your help regarding javascript code, how do I
i would like to ask for your help since I'm having difficulty resolving this
I would like to ask you about regular expressions preg_match have outlined below. I
I'd like to ask for your help concerning Android's built in Camera Interface When
Greeting everyone, may I ask your help for following question? I'm using following code
I'd like to ask for help with the two queries below. They work like

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.