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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:17:22+00:00 2026-06-10T16:17:22+00:00

I have a situation where I want to connect two tables that do not

  • 0

I have a situation where I want to connect two tables that do not have a key to link them within Oracle 8i. I have Table A with some information and a datetime and Table B with some information and a datetime. What I would like is everything from Table A with the corresponding data from Table B for the time in Table A I’ll mock it up below:

Table A                     |   Table B
John   31/07/2012 10:50:32  |   Travel to Library   31/07/2012 10:48:23
John   31/07/2012 10:55:49  |   Arrive at Library   31/07/2012 11:02:34
John   31/07/2012 11:00:15  |   Reading Book        31/07/2012 11:07:11
John   31/07/2012 11:05:23  |
John   31/07/2012 11:10:12  |

What I want to create is this:

John   31/07/2012 10:50:32   Travel to Library   
John   31/07/2012 10:55:49   Travel to Library       
John   31/07/2012 11:00:15   Travel to Library            
John   31/07/2012 11:05:23   Arrive at Library
John   31/07/2012 11:10:12   Reading Book

As might be suspected this is in relation to a table that contains GPS data that I receive every 5 minutes and another table completely unrelated that lists activities. My closest attempt so far has been to write a query in two parts the first part is looking at the activity and returning an activity date and a next activity date then connecting the two tables based on the name of the person involved and returning the GPS data when it is between the two activity dates, I’ve also done it the opposite way around with GPS date and Next GPS date and returning the activity if it is between those. Neither way is returning all of either set of data.

I feel that my major malfunction lies in my use of the leap/lag functions to get a before or after datetime. Perhaps I’m just overlooking the obvious answer.

I could really use some help to point me in the right direction with this.

  • 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-10T16:17:23+00:00Added an answer on June 10, 2026 at 4:17 pm

    Try this:

    select Name, Time, Activity from
    (
        select
            a.Name, a.Time, b.Activity,
            row_number() over (partition by a.Time order by b.time desc) as rn
        from TableA a, TableB b
        where a.time >= b.time and a.Name = b.Name
    )
    where rn = 1;
    

    Note: I assumed that the GPS data also comes with a name in the table.

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

Sidebar

Related Questions

I have a situation where I want a Java client to have a two-way
I have a situation where I want my program to read in some numbers
We have a situation where we want to use filter for URL's containing some
I have a specific scenario that I want to solve. I currently connect to
I have a situation. I want to connect to gmail smtp server and send
I have run into a difficult situation. I do not want to do my
Here's my situation: I have a file, homepage.php, that I want to allow my
I have a situation where I want a bash script to replace an entire
I have a situation where I want certain code to be executed no matter
I have a situation where i want to add LinePragmas to CodeDom objects. But

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.