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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:08:06+00:00 2026-06-11T05:08:06+00:00

Take the following example code: with test as ( select to_date(’01/2012′, ‘mm/yyyy’) as dt,

  • 0

Take the following example code:

with test as (
    select to_date('01/2012', 'mm/yyyy') as dt, '1' as value from dual union all 
    select to_date('02/2012', 'mm/yyyy') as dt, '10' as value from dual union all 
    select to_date('03/2012', 'mm/yyyy') as dt, '100' as value from dual union all 
    select to_date('04/2012', 'mm/yyyy') as dt, '2' as value from dual union all 
    select to_date('05/2012', 'mm/yyyy') as dt, '20' as value from dual 
)
select dt, value from test

which returns:

DT          | VALUE
1/1/2012    | 1
2/1/2012    | 10
3/1/2012    | 100
4/1/2012    | 2
5/1/2012    | 20

I wish I could build a new column containing the previous value of each record, such as:

DT          | VALUE  | Previous
1/1/2012    | 1      | -
2/1/2012    | 10     | 1
3/1/2012    | 100    | 10
4/1/2012    | 2      | 100
5/1/2012    | 20     | 2

Which seems simple enough though I constantly get lost with connect_by statements.

could someone help?

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

    No need to use a CONNECT BY. You just need a LAG

    SQL> ed
    Wrote file afiedt.buf
    
      1  with test as (
      2      select to_date('01/2012', 'mm/yyyy') as dt, '1' as value from dual union all
      3      select to_date('02/2012', 'mm/yyyy') as dt, '10' as value from dual union all
      4      select to_date('03/2012', 'mm/yyyy') as dt, '100' as value from dual union all
      5      select to_date('04/2012', 'mm/yyyy') as dt, '2' as value from dual union all
      6      select to_date('05/2012', 'mm/yyyy') as dt, '20' as value from dual
      7  )
      8  select dt,
      9         value,
     10         lag(value) over (order by dt) prior_value
     11*   from test
    SQL> /
    
    DT        VAL PRI
    --------- --- ---
    01-JAN-12 1
    01-FEB-12 10  1
    01-MAR-12 100 10
    01-APR-12 2   100
    01-MAY-12 20  2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the following C code as an example: char buffer1[5]; int* ret; printf(Buffer1 is:
When using the following example code, the tv_nsec value, I presume is looping round
Take following example of code: (ASP.NET WebForms) <asp:Content ContentPlaceHolderID=Contents runat=server> <div class=blogpost-list> <asp:Repeater ID=blogList
Take the following example, I have a class public class SomeItem { public string
Take the following example plugin: (function($) { $.fn.alertOnClick = function(text) { return this.each(function(){ $(this).click(alert(text));
Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is
Take for example the following regex match. preg_match('!^publisher/([A-Za-z0-9\-\_]+)/([0-9]+)/([0-9]{4})-(january|february|march|april|may|june|july|august|september|october|november|december):([0-9]{1,2})-([0-9]{1,2})/([A-Za-z0-9\-\_]+)/([0-9]+)(/page-[0-9]+)?$!', 'publisher/news/1/2010-march:03-23/test_title/1/page-1', $matches); print_r($matches); It produces the
Let's take for example a single file committed in CVS with the following history.
Take the following code snippet: SPAttachmentCollection attachments = item.Attachments ; What exactly is SPAttachmentCollection
Lets take a look at the following code: mongodb.js var mongo = require('mongodb') ,

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.