How to know the history have not null value

Hi all

I want to find records that have prior LOG_REVIEW_STAGE = "HHH" have (DT_LOG_BEGIN is not null and DT_LOG_END IS NULL and LOG_STATUS = pending)
based on the identification number

Thanks in advance
For Example my Ouput should be 

ID     SORT_ORDER     LOG_STATUS     LOG_REVIEW_STAGE     DT_LOG_BEGIN     DT_LOG_END
-----------------------------------------------------------------------------------------------
20     700          Pending          FFF               1/26/2004     
ID     SORT_ORDER     LOG_STATUS     LOG_REVIEW_STAGE     DT_LOG_BEGIN     DT_LOG_END
-----------------------------------------------------------------------------------------------
10     100          Complete     AAA               1/13/2004     1/13/2004
10     200          Complete     BBB               1/23/2004     1/23/2004
10     300          Pending          CCC               1/23/2004     
10     400                    DDD          
10     601                    EEE          
10     700                    FFF          
10     800                    GGG          
10     900                    HHH         ---------------------->>>>>>>>>
10     1000                    JJJ          
10     1100                    KKK          
20     100          Complete     AAA               1/13/2004     1/13/2004
20     200          Complete     BBB               1/23/2004     1/23/2004
20     300          Complete     CCC               1/23/2004     1/23/2004
20     400          Complete     DDD               1/24/2004     1/24/2004
20     601          Complete     EEE               1/25/2004     1/25/2004
20     700          Pending          FFF               1/26/2004     
20     900                    HHH          ---------------------->>>>>>>>>
20     1000                    JJJ          
20     1100                    KKK          
create table TEMP_TABLE
(
  id               NUMBER(2),
  sort_order       NUMBER(10),
  log_status       VARCHAR2(50),
  log_review_stage VARCHAR2(50),
  dt_log_begin     DATE,
  dt_log_end       DATE
)
;



insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 100, 'Complete', 'AAA', to_date('13-01-2004', 'dd-mm-yyyy'), to_date('13-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 200, 'Complete', 'BBB', to_date('23-01-2004', 'dd-mm-yyyy'), to_date('23-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 300, 'Pending', 'CCC', to_date('23-01-2004', 'dd-mm-yyyy'), null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 400, null, 'DDD', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 601, null, 'EEE', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 700, null, 'FFF', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 800, null, 'GGG', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 900, null, 'HHH', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 1000, null, 'JJJ', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (10, 1100, null, 'KKK', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 100, 'Complete', 'AAA', to_date('13-01-2004', 'dd-mm-yyyy'), to_date('13-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 200, 'Complete', 'BBB', to_date('23-01-2004', 'dd-mm-yyyy'), to_date('23-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 300, 'Complete', 'CCC', to_date('23-01-2004', 'dd-mm-yyyy'), to_date('23-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 400, 'Complete', 'DDD', to_date('24-01-2004', 'dd-mm-yyyy'), to_date('24-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 601, 'Complete', 'EEE', to_date('25-01-2004', 'dd-mm-yyyy'), to_date('25-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 700, 'Complete', 'FFF', to_date('26-01-2004', 'dd-mm-yyyy'), to_date('26-01-2004', 'dd-mm-yyyy'));
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 800, 'Pending', 'GGG', to_date('27-01-2004', 'dd-mm-yyyy'), null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 900, null, 'HHH', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 1000, null, 'JJJ', null, null);
insert into TEMP_TABLE(id, sort_order, log_status, log_review_stage, dt_log_begin, dt_log_end)
values (20, 1100, null, 'KKK', null, null);
commit;

Please provide examples of data, as well as an explanation of your logic. It is very useful!

I think that's what you want:

SELECT id
     , sort_order
     , log_status
     , log_review_stage
     , dt_log_begin
     , dt_log_end
FROM
(
        SELECT id
             , sort_order
             , log_status
             , log_review_stage
             , dt_log_begin
             , dt_log_end
             , LEAD(log_review_stage) OVER (PARTITION BY id ORDER BY sort_order) AS next_log_review_stage
        FROM   temp_table
)
WHERE  log_status            = 'Pending'
AND    dt_log_begin          IS NOT NULL
AND    dt_log_end            IS NULL
AND    next_log_review_stage = 'HHH'
;

When run on your dataset, it returns:

                  ID           SORT_ORDER LOG_STATUS      LOG_REVIEW_STAGE                                   DT_LOG_BEGIN        DT_LOG_END
-------------------- -------------------- --------------- -------------------------------------------------- ------------------- -------------------
                  20                  800 Pending         GGG                                                01/27/2004 00:00:00

If this is incorrect, please explain why.

Thank you!

Tags: Database

Similar Questions

  • How to avoid the link of a null value in a column of link

    Hello

    How to avoid the link of a column with the value zero. Is that the link should be disabled for the column with the value null, and it must be enabled for all that have a value.

    Ex

    DEPTNO NAME (link column)

    10 SCOTT
    20 MAC
    30 SMITH
    40         -
    50 SAM

    I don't want to link to the value null in the name column, but the name remaining should have link. Please help me.


    Kind regards
    Barro

    Hello

    One way is like this:
    1. create a column not displayed, called link_display in your report to return N or Y depending on whether you want the link by adding the SQL report:

        NVL2(name, 'Y', 'N') link_display 
    

    2. in the header of the region, define a class for the column name using:

    
    

    3. for the name column containing the link add link attributes: class = "" display_link_ #LINK_DISPLAY # ""

    Rod West

  • Column of the history is not retrieve value (Jdeveloper 11 g)

    Hello

    The columns of history are still null after I did insert on the table. My objects in view are based on object entities.

    I also tried running the AppModule service in the business model, remain null columns in the history. What can cause this? Any ideas would be greatly appreciated.

    More details:

    My Messages of IUCN has history columns, for example:

    < attribute
    Name = "DateInsr".
    ColumnName = "DATE_INSR."
    Type = "Oracle.jbo.domain.Timestamp"
    ColumnType = "TIMESTAMP".
    SQLType = 'TIMESTAMP '.
    TableName = "MESSAGES".
    IsUpdateable = "while_insert".
    HistoryColumn = "DateHistory".
    RetrievedOnUpdate = 'true '.
    RetrievedOnInsert = "true" >
    < DesignTime >
    < name Attr = "_DisplaySize" Value = "11" / >
    < / DesignTime >
    < data >
    < property
    Name = "ID".
    Value = "3d73c263-011f-1000-8017-89cf60e9a194:EntityObjectAttribute" / >
    < / data >
    < / attribute >


    And my view Electroniquesafficher object has associated source code:

    < ViewAttribute
    Name = "DateInsr".
    PrecisionRule = 'true '.
    EntityAttrName = "DateInsr".
    EntityUsage = "Messages".
    AliasName = 'DATE_INSR. '
    IsUpdateable = "false" >
    < data >
    < property
    Name = "ID".
    Value = "3d73c35d-011f-1000-803 b - 89cf60e9a194:ViewObjectAttribute" / >
    < / data >
    < / ViewAttribute >

    Thank you

    Valon

    3 things come to mind:

    (1) do you have database on the DATE_INSTR column triggers?

    (2) try to disable the refresh attribute EO after inserting/updating properties

    (3) test with a non-Timestamp column (just a date instead).

    CM.

  • How to know the number of changes of values in a single transaction?

    11 GR 2.
    RHEL 5.

    I have a batch process that evolves from the records in the table now, I want to find that, by transaction, how many values is changed?

    A vlause of VOTING would help?

    orcl>
    orcl> var n number
    orcl>
    orcl> update emp set sal=sal returning count(*) into :n;
    
    14 rows updated.
    
    orcl>
    orcl> print n
    
             N
    ----------
            14
    
    orcl>
    
  • How can I search all subjects in my guide? and if this is not possible, how do I get books have not not subjects with the same name?

    How can I search all subjects in my guide? and if this is not possible, how do I get books have not not subjects with the same name?

    "People need be able to find these without having to look inside each book TOC.

    Sorry, but I'm not a big fan or user of this sensitive arrangement "New kid on the block. Therefore, it may be that I am simply misunderstanding because I do not regularly use it. Of what you say, it seems to me that if you (or more precisely your users) are not able to click on the right side, where he says 'Getting Started' or 'List of Email Campaign' and see these topics open and view the content with search terms highlighted?

    Regarding the "bookmarks", those that are normally visible by the user and will be not viewable unless the name of the bookmark appears also as text within the topic. Although, if the two are different, you could probably get there by adding the name of the bookmark as a keyword search in the properties of the section.

    In any case, I feel that at this point, I can just be frustrating you and you may need someone else to try to help that probably better understand the issue.

    Sorry, I was not able to help.

    See you soon... Rick

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • How to delete the history of google, tried to delete the browsing history, that works, but it does not delete the site from google (in the middle of the page next to the images and videos

    How to delete the history in the Google search box in the middle of the page under Web new video Images

    http://www.Google.com/support/WebSearch/bin/answer.py?hl=en&answer=465

    See if help above.

    See you soon.

    Mick Murphy - Microsoft partner

  • How to remove the history tab.

    Despite the erasure of history, setting don't forget history forever, etc., always Firefox remember my history in tabs when I open a new tab. It shows some sites. This is clearly in direct opposition to clear the history settings I selected of course, violating my privacy.

    Apart from the cognitive dissonance of a browser that is supposed to guarantee completely insecurity, and people do not have stopped using it completely, I guess that anyone knows how to disable tab history, or people are naively using Firefox thinking that it is a secure browser.

    If the first is the case, and people do not know how to disable the history tab, I would like a clear explanation of how to do something not only a geek technique could understand.

    I found a solution to this problem clearly explained here:

    http://www.PCAdvisor.co.UK/how-to/Internet/3433031/how-stop-Firefox-from-exposing-your-browser-history-in-new-tabs/

    It's very sad that Firefox as the world down. It's as if they have forgotten the whole point of their browser.

  • How to clear the history of cats?

    Hello

    How to clear the history of cats for each new session?

    Thank you

    Pascale

    Hello Claudia,.

    Can you please check if the user that you are trying to connect with is a "presenter or host? If the user is not presenter or host, and is just a participant user won't be able to clear the history of cats. And in this case, you will most likely the error you get. Please try to give such a user the role 'Presenter' or ' home' then try again and see if it works.

    Let us know if this helped.

    Thank you

    Avinash

  • [JS] [CS5.5] how to know the position of the character in the story after grep?

    Hi all

    I wich know how can I know the position of the first character to the story of his mother, after a findGrep replace?

    As an example my story contain:

    Lorem ipsum dolor sit amet, adipiscing elit computer.

    I get dolor and replace it with TEST

    Lorem ipsum dolor sit amet, adipiscing elit computer TEST.

    How to know the position of T compared to history, when I get a PointInsertion after changeText?

    THX

    "PointInsertion" defines all the positions that you could ever want - see http://jongware.mit.edu/idcs5js/pc_InsertionPoint.html

    For "position relative to history" you may want to the index, which is 0 for the first character, 1 for the next (uh, and so on).

    petiout wrote:

    [...] When I get a PointInsertion after changeText?

    In fact, you do not get 'a PointInsertion', you get an array of references to objects in plain text. But the text is a superclass of PointInsertion (and much more "texty" classes), so, in general, it would be prudent to use any PointInsertion method and property as if you InsertionPoints.

  • How to view the history of the exams?

    I want to know how to make someone look at his history of review?

    801264 wrote:
    OK, this is how you show your certificate. But how to view the history of the review?
    I just spent a few hours ago 1Z0-051. Now, I want to see my own historical review. How can I do this? Via certview, or should I go directly to the website of pearson?

    Published by: 801264 on December 23, 2010 16:34

    Pearson VIEW find out of your exam at Pearson VIEW history... but he will not know about certifications.

    Certiview will be your story for review and certification. Are can be a lag of a few days between information get Pearson view at Certview.

  • How to know the degree of optimal parallelism for my database?

    I have an important application on my (Oracle 10,2,0) databae and the box has 4 CPU. All tables are not partitioned. Should I set the parallel degree by myself?

    How to know the degree of optimal parallelism for my database?

    As far as I am concerned there is no optimum degree of parallelism at the database level. The optimal value depends on the query based on the plan in use. This may change over time.

    It is not so difficult to abuse of the PQO and end up harming the overall database performance. PQO is a brute force methodology and should be applied with caution. Otherwise, you end up with results inconsisten.

    You can let Oracle manage, or you can manage it on the level of education through advice. I do not have to specify the degrees of parallelism to the object level. As I said, no two queries are exactly alike and what is right for a query on a table cannot be good for another query on the table.

    In the case of doubt put in place the system to let Oracle manage. If you ask really, it's how many sessions to allocate PQO then look at your reports Statspack or AWR and judge your system load. Monitor v$ px_session and v$ pq_slave to see how these views show activity.

    IMHO - Mark D Powell-

  • How to know the tables used in packages of a schema.

    How to know the tables used in packages of a pattern that I have connected.

    SELECT DISTINCT referenced_owner, referenced_name

    Of all_dependencies

    Owner WHERE = "MY_USER_NAME".

    AND type ('PACKAGE', 'BODY of PACKAGE')

    AND referenced_type = 'TABLE '.

  • How to know the schema of BIEE instance repository

    I have several BIEE instance and equivalent manner several repositories created by RCU. How to know the link between the repository and POET?

    Thank you

    Take a look on


    $FMW_HOME/user_projects/domains/bifoundation_domain/config/jdbc/mds-owsm-jdbc.xml

    The jdbc-driver-params shows you the database and the schema that it uses, which tells you what you want to know.

  • Fill with the previous 'not null' value ' Null' known values

    Hi all

    I have the following requirement to fill in missing values (null values) with the "Not null" values known previously available.

    Source of the example:

    Emp_Id Start_Dt LOC Comm Grade

    A101

    01/01/2013

    NJ4000B

    A101

    15/03/2013

    CA4800

    A101

    15/05/2013

    3500C

    A101

    25/07/2013

    2500

    A101

    20/12/2013

    NY5800A

    A101

    14/02/2013

    5000

    A101

    20/05/2014

    DC6000A

    A101

    03/06/2014

    3600C

    A102

    24/05/2013

    THE5000A

    A102

    15/12/20134300

    Expected results values in columns LOC and grades:

    Emp_Id Start_Dt LOC Comm Grade
    A101

    01/01/2013

    NJ4000BA101

    15/03/2013

    CA4800BA101

    15/05/2013

    CA3500CA101

    25/07/2013

    CA2500CA101

    20/12/2013

    NY5800AA101

    14/02/2013

    NY5000AA101

    20/05/2014

    DC6000AA101

    03/06/2014

    DC3600CA102

    24/05/2013

    THE5000AA102

    15/12/2013

    THE4300A

    Any suggestions would be helpful.

    Kind regards

    Arun

    Also, I think that this is a case of analytics. Last_value is perhaps the most appropriate function for the given task:

    Select emp_id

    start_dt

    last_value(loc ignore nulls) over (partition by emp_id arrested by start_dt) loc

    comm

    last_value(grade ignore nulls) about category (partition by emp_id arrested by start_dt)

    t

Maybe you are looking for

  • HP Pavilion dv6-6170us: upgrade HP Pavilion dv6-6170us

    I have the hp Pavilion dv6-6170us and I was wondering if there is a way to update my graphics card, the Radeon HD 6770 M, I tried to look for more information, but I couldn't find the product on the hp site.

  • How can I block websites?

    Separated from this thread. I need to know how to block outlook.com my computer and other sites as well.  My boyfriend is using my computer and the connection to Facebook.  Absolutely, I hate Facebook and do not want it on my computer.  I really need

  • Remote parental control

    I have windows vistaI have put parental controls in place on 2 computers at home.My kids use the computer 2 in another room.I want to be able to monitor what they do on the InternetCan I follow this my main computor. Can't see how to do this

  • Windows 8 struck looping self-repair

    My inspiron 660 is struck in a self-healing loop Last night, I was watching a dvd, my pc freeze and since I can not restart. He's trying to fix then to restore then nothing happens

  • Power supply Dell Vostro 220 questions

    Hello We have a Dell Vostro 220, which has power problems.  He started intermittently but now it very rarely powers upward. The green light in the back where the power cable goes in turns. When I press the switch, it flashes orange once. Then the two