Mark the Date based on the value of the following line... Delivery very Urgent

Hello guys

I work as a Business Intelligenece Developer and one of my reports, I have a requirement where I have a Date column and the date should be in ascending order IE 1 - JAN - 09
2-JAN-09
1 - FEB - 09

If the date is not in ascending order, I need to mark the Date

Here are examples of data

Flag - Here if the Date is not in the order I have to report it Print N, i.e. If the date is growing Null we ignore and check the
Next Date sequence Vale line
10215 P02095
10220 P02095
P02095 10500 13 March 01
P02095 10600
P02095 30-Sep-10610 04
P02095 10960
P02095 N 10990 05 - Sep - 01
P02095 20015 1 May 02 N
P02095 20020 23 April 01 N
P02095 20030 23 April 01 N
P02095 50000
P02095 63500
P02095 64000
P02095 64100 18 December 06
P02095 64125
P02095 64400 16 March 07
P02095 64500 16 April 07
P02095 64550 17 April 07
P02095 70000 23 April 07
P02095 70100 27 April 07
P02095 80000 April 30 07
P02095 81050
P02095 81100
P02095 83000
P02095 84000
P02095 14-Sep-86000 07
86050 P02095
86230 P02095


Let me know if you have any questions I'll post it, thank you

You did not post the version of Oracle, so I'll assume that you're at least 10g. Then the MODEL would be the best solution:

with t as (
           select 'P02095' col1,'10215' seq,null dt from dual union all
           select 'P02095','10220',null from dual union all
           select 'P02095','10500',to_date('13-Mar-01','dd-mon-rr') from dual union all
           select 'P02095','10600',null from dual union all
           select 'P02095','10610',to_date('30-Sep-04','dd-mon-rr') from dual union all
           select 'P02095','10960',null from dual union all
           select 'P02095','10990',to_date('05-Sep-01','dd-mon-rr') from dual union all
           select 'P02095','20015',to_date('01-May-02','dd-mon-rr') from dual union all
           select 'P02095','20020',to_date('23-Apr-01','dd-mon-rr') from dual union all
           select 'P02095','20030',to_date('23-Apr-01','dd-mon-rr') from dual union all
           select 'P02095','63500',null from dual union all
           select 'P02095','64000',null from dual union all
           select 'P02095','64100',to_date('18-Dec-06','dd-mon-rr') from dual union all
           select 'P02095','64125',null from dual union all
           select 'P02095','64400',to_date('16-Mar-07','dd-mon-rr') from dual union all
           select 'P02095','64500',to_date('16-Apr-07','dd-mon-rr') from dual union all
           select 'P02095','64550',to_date('17-Apr-07','dd-mon-rr') from dual union all
           select 'P02095','70000',to_date('23-Apr-07','dd-mon-rr') from dual union all
           select 'P02095','70100',to_date('27-Apr-07','dd-mon-rr') from dual union all
           select 'P02095','80000',to_date('30-Apr-07','dd-mon-rr') from dual union all
           select 'P02095','81050',null from dual union all
           select 'P02095','81100',null from dual union all
           select 'P02095','83000',null from dual union all
           select 'P02095','84000',null from dual union all
           select 'P02095','86000',to_date('14-Sep-07','dd-mon-rr') from dual union all
           select 'P02095','86050',null from dual union all
           select 'P02095','86230',null from dual
          )
select  col1,
        seq,
        dt,
        indicator
  from  t
  model
  dimension by(col1,row_number() over(partition by col1 order by seq) rn)
  measures(dt,seq,cast(null as varchar2(1)) indicator,min(dt) over(partition by col1) x)
  rules(
        x[any,rn > 1] order by rn = greatest(nvl(dt[cv(),cv()],x[cv(),cv() - 1]),x[cv(),cv() - 1]),
        indicator[any,any] = case when nvl(dt[cv(),cv()],x[cv(),cv()]) != x[cv(),cv()] then 'N' end
       )
/

COL1   SEQ   DT        I
------ ----- --------- -
P02095 10215
P02095 10220
P02095 10500 13-MAR-01
P02095 10600
P02095 10610 30-SEP-04
P02095 10960
P02095 10990 05-SEP-01 N
P02095 20015 01-MAY-02 N
P02095 20020 23-APR-01 N
P02095 20030 23-APR-01 N
P02095 63500

COL1   SEQ   DT        I
------ ----- --------- -
P02095 64000
P02095 64100 18-DEC-06
P02095 64125
P02095 64400 16-MAR-07
P02095 64500 16-APR-07
P02095 64550 17-APR-07
P02095 70000 23-APR-07
P02095 70100 27-APR-07
P02095 80000 30-APR-07
P02095 81050
P02095 81100

COL1   SEQ   DT        I
------ ----- --------- -
P02095 83000
P02095 84000
P02095 86000 14-SEP-07
P02095 86050
P02095 86230

27 rows selected.

SQL> 

SY.

Published by: Solomon Yakobson on January 23, 2010 10:31

Tags: Database

Similar Questions

  • How to mark the current line in the grid forms

    How to mark the current line in the grid of forms in forms

    There is no grid in use in forms
    However, you were using the ORACLE spreadsheet in the OCX element before 10g in forms5.
    You can use the property of coloring of the ORACLE worksheet if you use older forms.

    If you speak the text displayed in the instances multile means with more display records. then you can use the Visual Attirbute
    and may affect the block attribute in current folder to the Visual attribute you make now.

  • Remove the following lines

    Hi all

    with tbdate as

    (

    Select 6 March 2013 08:00 ' date1, n1 10 'x 1' oggetto in all double union '.

    "Select 6 March 2013 08:10 ', 20 ' x 2' of all the double union

    "Select 6 March 2013 08:20 ', 10 ' x 3' of all the double union

    "Select 6 March 2013 08:30 ', 20 ' x 4' of all the double union

    "Select 6 March 2013 08:40 ', 10 ' x 5' of all the double union

    "Select 6 March 2013 08:50 ', 30 ' x 6' of all the double union

    "Select 6 March 2013 09:00 ', 10 ' x 7' of all the double union

    "Select 6 March 2013 09:10 ', 20 ' x 8' of the double

    )

    Select a.* tbdate one

    How can I remove the lines where the total (date1 + numtodsinterval (n1, "MINUTE")) of the previous line does not match the line or the following lines?

    With example maybe I'll be more clear

    rank 1 03/06/2013 08:00 10 x 1 Yes

    rank 2 03/06/2013 08:10 x 30 2 Yes because more time minutes (n1) of the largest previous = 08:10 equal this line

    rank 3 03/06/2013 08:20 10 x 3 not because 08:10 + 30 = 08:40 previous line <>this line

    rank 4 03/06/2013 08:30 20 x 4 not because 08:10(rows_2) + 30 = 08:40 of the previous lines (2 lines) <>this line

    rank 5 03/06/2013 08:40 10 x 5 Yes

    tier 6 03/06/2013 08:50 x 20 6 yes because 08:40 plus 10 = 08:50 from the previous row is this line

    tier 7 03/06/2013 09:00 10 x 7 no

    tier 8 03/06/2013 09:10 10 x 8 Yes

    Thanks in advance

    Hello

    You build the correct path and connect (and then delete the others):

    SQL dts@QUALIF > with tbdate like

    () 2

    3 select to_date (6 March 2013 08:00 ',' dd/mm/yyyy hh24:mi:ss') date1, n1 10 'x 1' oggetto in all double union '.

    4 Select to_date (6 March 2013 08:10 ',' dd/mm/yyyy hh24:mi:ss'), 20, 'x 2' dual union all '.

    5 Select to_date (6 March 2013 08:20 ',' dd/mm/yyyy hh24:mi:ss'), 10 'x 3' double union all '.

    6 select to_date (6 March 2013 08:30 ',' mm/dd/yyyy hh24:mi:ss'), 20 'x 4' double union all '.

    7 select to_date (6 March 2013 08:40 ',' dd/mm/yyyy hh24:mi:ss'), 10 'x 5' double union all '.

    8 select to_date (6 March 2013 08:50 ',' dd/mm/yyyy hh24:mi:ss'), 20 'x 6' double union all '.

    9 select to_date (6 March 2013 09:00 ',' dd/mm/yyyy hh24:mi:ss'), 10 'x 7' double union all '.

    10. Select to_date (6 March 2013 09:10 ',' dd/mm/yyyy hh24:mi:ss'), 20 'x 8' from dual '.

    (11), a title)

    12. Select b.*, sys_connect_by_path (oggetto, '-') pth, connect_by_root (oggetto) r, prior (oggetto) p

    tbdate 13 b

    14 connect by date1 = prior date1 + prior n1 / 24 / 60

    15 beginning with oggetto = 'x 1') '.

    16. Select * from a;

    DATE1            N1 OG PTH                                                R  P

    -------- ---------- -- -------------------------------------------------- -- --

    03.06.13         10 x1 -x1                                                x1

    03.06.13 20 x 2 - x 1 - x 2 x 1 x 1

    03.06.13 20 x 4 - x 1 - x 2 - x 4 x 1 x 2

    03.06.13 20 x 6 - x 1 - x 2 - x 4 - x 6 x 1 x 4

    03.06.13 20 x 8 - x 1 - x 2 - x 4 - x 6 - x 8 x 1 x 6

  • Get the value of the following line in the game ordered under certain conditions

    Do not know if my best subject line sums up what I do :)


    Oracle DB 12 c (I think 12.1.2)


    I have a table with the names of people and DOB with a few keystrokes. It is assumed that this person is the 'same' first_name, last_name, birth_day/month/year are identical

    drop table people;

    create table persons

    (

    first name varchar2 (30),

    VARCHAR2 (30) last_name,.

    birth_month varchar2 (2),

    birth_day varchar2 (2),

    birth_year varchar2 (4).

    keyVal number

    );

    insert into values('JOHN','SMITH','10','10','1974',1) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('JOHN','SMITH','10','10','1974',2) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('JANE','SMITH','10','10','1974',3) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('JANE','DOE','10','10','1974',4) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('JANE','DOE','10','10','1974',5) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('ERIC','DOE','11','10','1975',6) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('ERIC','DOE','11','10','1975',7) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    insert into values('ERIC','DOE','11','10','1975',8) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

    I want to see the following output:

    first_name, last_name, birth_month, birth_day, birth_year, keyval_min, keyval_other

    JOHNSMITH101019741 2
    JANEDOE101019744 5
    ERICDOE111019756 7
    ERICDOE111019756 8

    1. the output will display only those who appear at least twice in the original table

    2. If the person appears twice in the original table, the output will only one result where first keyval will be min two; second keyval will be the other value;

    3. If the person has 3 times or more (n times, for example), each line of output will be keyval_min of all keyvals followed by the other value keyval. Total of n-1 lines

    It's very large 100 + M and the processing time is important.

    Hope I explained it well.

    Hello

    This sounds like a job for analytical functions.

    If the same person has N rows in the table, the output should be N - 1 lines.  You can use the ROW_NUMBER analytic function to assign numbers (1, 2, 3,...) to each line and do not display the lines nuimbered 1.

    On each line, you must prove the keyval lowest for this person.  The analytical MIN function can do this.

    Here's one way:

    WITH got_analytics AS

    (

    SELECT first_name, last_name, birth_month, birth_day, birth_year, keyval

    , ROW_NUMBER () OVER (PARTITION BY first_name, last_name, birth_month, birth_day, birth_year)

    ORDER BY keyval

    ) AS r_num

    , MIN (keyval) OVER (PARTITION BY first_name, last_name, birth_month, birth_day, birth_year)

    ) AS keyval_min

    AMONG the people

    )

    SELECT first_name, last_name, birth_month, birth_day, birth_year

    keyval_min

    keyval AS keyval_other

    OF got_analytics

    WHERE r_num > 1

    ORDER BY first_name, last_name, birth_month, birth_day, birth_year

    r_num

    ;

    Use the data DATE to the date information type.  With the help of 3 columns separate NUMBERS will result in complicated, ineffective, code errors and invalid data.

  • Data to be displayed in the following line

    Hello

    We have created a report that displays columns as the field name and the comment of the employee. I noticed that after10 character the remaining data is displayed on the next line.
    Is it possible to displlay data in the same row?

    Any help is greatly appreciated.

    Thank you
    Poojak

    Hello
    Use white space without film under CSS custom to the title column and column values in order to have them in a single line.
    Reference: http://oraclebi.blog.com/tag/data-text-wrap-in-obiee/

    Kind regards
    Srikanth

  • Cells in consecutive sheets may include the following line in a master spreadsheet

    Hello. I have a master sheet of orders for that customer. I want to build another spreadsheet "invoice" for each line of this master worksheet. Is anyway to do (except manually by selecting the required master line as I build each sheet)?

    Thank you

    Without specific details (including screenshots), it will be difficult to answer.  Figures has functions that can get data using various methods.

    Indirect(), offspring, Lookup(), vlookup() and hlookup() are functions that can help you

  • Please answer the basic questions, thanks, very urgent!

    What is the difference if I check or uncheck the 'records of the kind' and 'sort items"when the wizard in step 5 of creating a new folder.

    Thank you very much!!

    If activate you folder sort options, you have created the folders inside the BA will be sorted in alphabetical order
    It goes the same for items - it will sort the items inside each folder.

    If you uncheck the order will be the order that you added the files or the order of the elements based on the underlying object.

    Somehow after the import is complete you can easily change the order by dragging objects upwards or downwards.

  • How to download the bb10 built server - very urgent

    Hello

    I created an application, he signed... What are the files to be transferred to the server so that I can download the application on the link... I am struck here do not how to download bb10 application from a link of our own... Tell me the files I need to download...

    Beginning of os7 I allows to add all present jad and cod files in the web folder of deliverables...

    Please help its very urget

    Concerning

    Rashmi

    BB10 apps cannot be installed OTA as BBOS app. You can sideload .bar files by using a program such as DDPB. Except that you must download the BB world

  • In adobe muse Im getting the following error, say: "very big limitations contained (W:12903330.289490186 H:953897.3592778504) detected in BoxUtils::childBounds. I made a composition and by mistake, he has increased the size above the limits, Im not able t

    I need to get this fixed ASAP

    If you haven't already done so, please send us the .muse to [email protected] file as well as a link to this topic. If the file is larger than 20 MB, you can use a service like Adobe SendNow, Dropbox, WeTransfer, etc.. Thank you.

  • How can I change the color of the plots (lines, points) in the collection Scattergraph plot

    For example, I go through a foreach loop and draw two points. How to distinguish this set of plots of the yet to come? How can I change the style, color and have separate lines (instead of on the line connecting everything) for each of my plots? I don't know how to set everything up, but it still does what he wants to do. TIA.

    Hello

    The problem you see occurs because of the following lines of code:

    The _data and _data2 scatterPlot3 value

    _data = scatterPlot3

    _data2 = scatterPlot3

    When you do this, you define _data as _data2 to reference an object of the simple concession - scatterPlot3.  Yes, even if you have (from the code you have posted at least) three slots in your collection, they are all pointing to the same object of point cloud.  So when you change the color for one, it changes the color for them all.  However, I think that you have fallen on the right solution in your last sentence.  If you want to have multiple locations on your ScatterGraph, each with its own color and style, they should each be separate and unique plots in the collection plot of your ScatterGraph.  Based on the code you posted, you'll see this if you comment just the two lines shown above.

    Please let me know if something is still uncertain.

    NickB

    National Instruments

  • Indentation under the last lines of the text

    If I want to indent a line, sometimes I use the SPACEBAR for Bar\Tab, and it works fine. However, other times the I can't do either. How can I activate my computer let me dash when this happens?

    The right way to indent second and following lines of a paragraph depends on whether you have a predetermined amount of the desired hyphen, or if you want to do it at a random point.

    For a preset indent, consistent for all paragraphs create a style and add a withdrawal left the correct amount, then a first line indent to match negative. Back to a random point based on the text you type, insert a special character withdrawal up to this point, where you want the following lines to start.

  • Links out to the new line?

    I am currently working on a new site based on CSS on a test server.

    I came up against a problem that makes no sense. Links included in the text to other pages or the destinations which have a CSS hover effect sometimes appear on a single line (correct), but at other times the line of text break on the following line when either before I hover over the link or after. This then breaks the flow of the page instead of the background color showing just behind the link. because of the lines of fracture to the other line shows effect hover on the full range?

    It is not systematically; It comes and goes; I don't see where it comes from; two lines that contain links will appear exactly the same in construction, but react differently with the mouse?

    Any help with this problem would be greatly appreciated. 2 links behave differently on the same page?

    > [b} #column a: link, a: visited {I thought would cover the rules]
    > for
    > the right column.

    Not quite.

    This is known as grouping the descendant selectors in a list separated by commas.

    However, each item in the list (between commas) is treated independently.

    "#column a: link, a: visited" is the same as #column a: link {;} rules more
    a: visited {rules ;}

    After the comma, he must again specify the id selector "#column" then
    Display: block applies only to one: went inside the '#column '.

    In other words, "#column a: link, a: visited" should be "#column a: link,
    "#column a: visited.

    As it is written currently, all States visited the tag is set to
    Display: block, which causes the break on lines after having clicked on everything
    link in the body of the text.

    --
    Concerning

    John Waller

  • How can I remove capital letter at the beginning of each sentence after the first line?

    Whenever I run a second line on any text document, it always starts with a capital letter. Each line does after that. The only time where this does not occur is when I do not use a hard to return.

    Thank you all. I guess that the ' CR ' would have been a better word to use in the description of my problem.  What I'm trying to describe everything that, unless I finished a line of text that is passed automatically to the next sentence, he has begun with a capital letter. Whereas, every time I didn't finish a whole line, the following line (or lines) always begins with a capital letter.

    However, I found my answer somewhere in Format I think and solved the problem. Thanks again to all for your responses and interest in helping.

  • When I try to use the Windows updates to and the following error message: Windows update cannot currently check updates, because the service is not running

    have tried to use windows update and get the following error message: Windows update cannot currently check the updates, because the service is not running. You may need to restart you computer. I rebooted several times. Any help would be greatly appreciated as I am not very computer

    Original title: update windows

    Solution 1:

    Try this: http://helpdeskgeek.com/windows-7/cannot-run-windows-update-on-a-windows-7-pc/

    Solution 2:

    You can try to stop and restart the Windows Update Service (wuauserv). Open a command line window (run as administrator) and enter the following lines:

    net stop wuauserv
    regsvr32 %windir%\system32\wups2.dll
    net start wuauserv

    If this does not help, try Microsoft Fix It service to reset your Windows Update components:

    http://support.Microsoft.com/kb/971058/en-us

    I hope this helps.

  • the following code


    Hello

    When you insert a new record I want to assign the next property-ID in the property.property_id table. The query:

    < name cfquery = "GetNewID" datasource = "#application. DSN_Name #">"
    SELECT top 1 property-ID
    PROPERTY
    ORDER BY property-ID desc
    < / cfquery >

    When I test it works swell.

    However, the error appears on the following line of code:
    < cflocation url = "add_property_confirm.cfm? property_id = #GetNewID.property_id #" >

    The error indicates that property-ID is not defined in GetNewID.

    The table property-ID is set to automatic and custom numbering and using SQL 2000.

    I have no idea where start solve this - as an interesting oddity that this code worked for years, the customer pulled the site down, and then we returned it - nothing has changed in the database or the code... a mystery to me.

    Thanks in advance,

    Kathy

    Hey - I figured it!

    The piece of code:

    Need double quotes:

    He now works as it should. This error message a fraction which created a very large problem.

    Thanks for all your comments - I really appreciate the time and thought that you gave my situation.

    Take care

    Kathy

Maybe you are looking for