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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:45:11+00:00 2026-05-25T18:45:11+00:00

please help, tried different queries with no luck in Oracle environment. To simplify the

  • 0

please help, tried different queries with no luck in Oracle environment. To simplify the case, assume that we have one table with records like this

doc_id   doc_date  product_id price
1       01.01.2011    1       20.3
1       01.01.2011    2       10.0
2       15.01.2011    3       10.3
2       15.01.2011    2       null

So, the price for product is set by document from doc_date till next doc_date or to infinity if no more document which sets the new price or reset it to null exists, null means that product sales is not available starting from doc_date.

I need a select which “unrolls” the data in the form:

doc_id   from_date   to_date    product_id price
1        01.01.2011  null          1        20.3
1        01.01.2011  14.01.2011    2        10.0
2        15.01.2011  null          2        null
2        15.01.2011  null          3        10.3

or even:

doc_id   from_date   to_date    product_id price
1        01.01.2011  14.01.2011    1        20.3
1        01.01.2011  14.01.2011    2        10.0
2        15.01.2011  null          2        null
2        15.01.2011  null          3        10.3
any      15.01.2011  null          1        20.3

Thanks!

  • 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-25T18:45:12+00:00Added an answer on May 25, 2026 at 6:45 pm
    Select 
      doc_id, 
      doc_date as from_date,
      (lead(doc_date) over (partition by product_id order by doc_date) ) - 1  as to_date,
      product_id, 
      price
    from
      product_table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys Please help me to solve this floating problem.I tried different methods but anything
Please help me with an issue that I have come across during work. I'm
Please help! Background info I have a WPF application which accesses a SQL Server
Please help me understand how the process goes. I understand that web browsers contain
I tried myself for another queries but this one is more complex for me
I have searched high and low and tried multiple different solutions to this and
I have tried different options and also the ones posted on stackoverflow. But nothing
I have 4 different queries and each of them return individual unique set of
Please help! I'm really at my wits' end. My program is a little personal
Please help me with a sanity check. Assuming a many-to-many relationship: Post, PostTagAssoc, Tag

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.