How to find the date of a table Max

Hello world

I have two tables in the database. I want to find the maximum routine for a case_id of the lock_date date between jan 20 to January 29, 2012.

But I don't get real output (output routine_date should be 'January 28, 2012' but I m getting "January 31, 2012" ")

Can someone help me where I made the mistake


Master
case_id lock_date
101 23 January 2012
101 January 24, 2012
102 27 January 2012
102 January 29, 2012
101 30 January 2012
101 January 29, 2012

Routine (for current work)
case_id routine_date
101 23 January 2012
103 28 January 2012
102 21 January 2012
102 January 29, 2012
101 21 January 2012
101 28 January 2012
101 31 January 2012


Select m.case_id, r.routine_date from master m, systematic r,
(case_id, max (routine_date) of the systematic group by selecting case_id) rr

where m.case_id = r.case_id
and m.case_id = rr.case_id
and r.routine_date = rr.routine_date

Hello

Here are average dradles:

WITH     universe  AS
(
     SELECT    m.case_id
     ,        r.routine_date
     ,       MAX (r.routine_date)     OVER (PARTITION BY  m.case_id)
                     AS max_routine_date
     FROM       master       m
     ,        routine       r
     WHERE        m.case_id       = r.case_id
     AND       m.lock_date       >= TO_DATE ('20-Jan-2012', 'DD-Mon-YYYY')
     AND       m.lock_date       <  TO_DATE ('30-Jan-2012', 'DD-Mon-YYYY')
)
SELECT       case_id
,       routine_date
FROM       universe
WHERE       routine_date     = max_routine_date
;

You only want to view rowss whose routine_date is the maximum date in a subset. First get this subset
If the universe of data that you are interested in is just the period from January 20 to January 29, then you can start by getting all the data in this range. This is what the above subquery universe.
Now, you want to see only the rows where routine_date is the max_routine_date within this universe, for each case_id. You can use the analytic MAX function to find out what this max_routine_date.
Published by: Frank Kulash, March 2, 2013 11:59

Tags: Database

Similar Questions

  • How to find the data in two tables are the same?

    Hi people,

    Suppose we have table emp01, have 10 records and create another emp02 as table

    create the table emp02 in select * from emp01;

    now both the table has the same data.

    How to find a 'data' in the two tables are the same?

    Hello

    SELECT *
    FROM emp01
    MINUS
    SELECT *
    FROM emp02
    UNION
    SELECT *
    FROM emp02
    MINUS
    SELECT *
    FROM emp01
    

    You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.

    Best regards
    Nikolai

  • How to find the date item was my favorites on Mozilla Firefox

    on system moot bookmark how to find the date of the bookmark?

    In bookmarks menu select organize bookmarks to open the bookmarks library. In the bookmarks library, click views, and then display the columns and then added. This will display a column showing when a bookmark has been added.

  • average of k: how to find the data clustred; : or how to assign number t0 each data group

    Hi Member

    I have download the LabVIEW Machine https://decibel.ni.com/content/docs/DOC-19328 learning package

    I want to run the K average algorithm to group the image in a group of two or three or more

    the problem is how to find the result I mean the image of clustred', the image that contain 2 or three threatened value only

    or how aasign a 1 value for all the intesity who

    belong to the cluster a and 255 for data that belongs to group 2

    for the look of the image as binary image?

    a my vi below

    Best regards

    my post before shows how to set the threshold manually using the slider of the graph.

    Here is the version k-means automated help .vi box tools

    Alex

  • How to find the date of purchase of my windows?

    I don't know the Date of purchase of windows, I can find it using the product key? or another procedure?

    Really, there is no way to find the date of purchase by using a Windows installed, Windows Installer CD or product key.   You need to find the original "Bill" room, you bought your computer or Windows.

  • Kindly help me with the request to find the data in two tables

    Hello Guru

    Kindly help me to recover the data from two tables-

    BASEBALL
    LEGAL_ENT_ID (PK)
    GAME_ID (FK)
    LEGAL_ENT_NM
    INACTIVE_DT
    DATE OF INS_TS
    INS_LOGIN
    DATE OF UPD_TS
    UPD_LOGIN


    FOOTBALL
    GAME_ID (PK)
    BRKR_NM,
    BRKR_ISR_ID
    BROKER_SYMBOL
    INACTIVE_DT
    BRKR_SWIFT_FLG
    BRKR_INTERNAL_FLG
    BRKR_CATEGORY
    UPD_TS
    MINORITY_FLG
    BROKER_TYP
    STATUS
    INS_TS
    INS_LOGIN
    UPD_LOGIN
    APP_USER
    ACTIVE_FLG

    and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.

    1 select distinct values only table of BASEBALL by using the following query.

    SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID

    2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next

    SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER

    Now, my query is that--

    I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.

    I like the result to look like who has a few conditions such as -
    1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
    2 - football is a superset of records and Baseball is a subset.
    3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.

    I want the result to be in the following form-

    EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
    2123 test1 2345 test5
    2456 test10 2456 test10


    Thanks in advance. Kindly help me.

    Published by: user555994 on January 4, 2011 23:48

    In the output you want.
    All the values of baseball;
    Values of football that are matched;
    But on what condition you want to match?

  • HOW TO FIND THE DATE

    Hi all

    I WANT TO SEARCH BY DATE BY PRESSING THE BUTTON

    My key code is like this
    declare
         l_where varchar2(4000);
    begin
          
      if :search_type = 'ALL' then
           l_where := 'ENTER_DATE||REPLY like ''%'|| :serch_value ||'%''' ;  
      else
           l_where := :search_type ||' like ''%'|| :serch_value ||'%''';
       end if;
        set_block_property('ALARM',default_WHERE,l_where);
           go_block('ALARM');
          execute_query;
    end;
    
    
     and My table is Like that
    
    
    
    SQL> desc alarm
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------
     QUESTION_UK                                        VARCHAR2(500)
     REPLY_UK                                           VARCHAR2(500)
     ENTER_DATE                                         TIMESTAMP(6)
     REPLY                                              VARCHAR2(20)
    I have a class where I put the value of the response or enter_date but when I put the value of rply does it work

    but when I enter the date she did ' t work

    Thanks and greetings
    Vikas Singhal

    Published by: vikas singhal on July 28, 2009 17:29

    Published by: vikas singhal on July 28, 2009 17:30

    Published by: vikas singhal on July 28, 2009 17:31

    1. you must explicitly convert your date to a char, if you really want to do a string comparison:

    l_where := 'TO_CHAR(ENTER_DATE, ''DD.MM.YYYY'') ||REPLY like ''%'|| :serch_value ||'%''' ;  
    

    but know that you lose any evidence on the one hand, and the search results depends on how users search on the other hand his condition.

    2. I would go with two separate search boxes, then you can do a comparison of date "clear."

    3. you talked about DATE fields now, why do you use a TIMESTAMP type of data in your table then?

  • How to find the dependence of a table

    Hi all

    How to find all packages or procedure which are using specific table. is there a table where we can go and search.
    I want to say I called table_A table say and I want to find in what procedure or package will use this table.

    Thank you
    Sree

    Hello

    Query user_source

    Concerning
    Sarah

  • How to find the data of missind

    Hello
    Please could someone point me in the direction of where to start to investigate this problem.

    Some transactions that were recently created in our database appear to be missing. At the moment I have not enough information on these transactions are stored in the tables, and as such, I am not able to query the tables again.

    However, I just thought that first ask more experienced people. What steps would you take to investigate such a problem? Outside querying tables when I get the names, what other tables can I query to see what happened in the database over a period.


    In addition, the only change I made to the database, because the transactions were was to expand the size of the data file for one of the tablespaces, would it have caused any problem? I only did increased the value of maxsize for file data.

    Thank you.

    Published by: user8869798 on June 2, 2011 07:45

    No, the increase in size will not erase the data already inserted. Are you sure that none came into your db without permission and has deleted the data? Do you audit put in place in your DB? What is the version of db of yours? If you are on 10g or above it and if your Undo retention has not been crossed, perhaps you can get the data more easily using the Flashback, using the package dbms_logmnr seems to be the only solution that you got IMO.

    Aman...

  • How to find the Date and the time of Installation of Oracle on Windows?

    Hello

    Is it possible to find the installation Date and time of Oracle on Windows?


    Concerning
    Rajesh

    If you have never recreated/restored/reincarnated the database, then COLUMN of v database $ should tell you when you created the database.

    If you are looking for the time of installing Oracle home, check the logs under OraInventory.

    Reply by Satish sir at the following link:
    installation of a database date/time!

    HTH
    Girish Sharma

  • How to find the date that a bookmark was made?

    It does not work:
    Go to the Menu bookmarks > show all bookmarks, then click Date of visit, top right middle.

    The visit Date column is just blank.

    If you want that the date on which the bookmark was created, then you have the added column.

    Make sure you keep the history and are not in private browsing mode in the visits column is empty.

  • How to find the date of a backup folder was added rather than created

    In a project of University I regularly saved the folder on a USB key. However, I'm not sure of the date I took the last backup. When looking at the Properties folder it says 'Date modified', but it is the date of the original folder has changed, not the date, that the file has been added on the USB. Is there anyway that I can get the date that I put the file on the USB key.

    Thank you
    Katherine Ellis

    Hello

    You can access the properties of the backup folder and see the 'creation Date'.

    Date created shows the date where the data are saved in the USB.

  • How to find the date, I bought creative cloud so to know if I am eligible for free hosting sites.

    Hello


    I want to know if I am eligible for the free sites, I'm aware that the end date is April 30, 2015. I don't know if I am registered before or after the deadline. In addition, apply to students in terms of students and teachers? I intend to launch a Web site shortly and I want to know if I would save money with Adobe Business Catalyst launch. Thank you

    Hello

    You can check the date in the history of the order under your account on Adobe.com.

    Kind regards

    Sheena

  • How to get the second clue high table max and min

    Hello

    I need help to find the second clue to the data table, how can I do?

    Secure with the extract of vi.

    Thank you and best regards,

    Simon

    You forgot to make the comparison to see where the 2nd most high index has declined compared to the highest.

    You only add 1 if the 2nd above comes after the highest.  You added 1 regardless of the position.

  • How to find the size of a table with CLOB

    Hello

    I have a table with CLOB as follows:

    SQL > desc INFO_MESSAGES

    Name                                      Null?    Type

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

    CLNT_OID NOT NULL VARCHAR2 (16)

    USR_OID NOT NULL VARCHAR2 (16)

    LAST_client_msg_ID VARCHAR2 (36)

    LAST_client_msg_DATE DATE

    LAST_client_msg CLOB

    LAST_USR_MSG_BOD_ID VARCHAR2 (36)

    DATE OF LAST_USR_MSG_DATE

    CLOB LAST_USR_MSG

    Now I just want to find out what is the size/area total absorbed by the table (including the CLOB columns), so how can I find? I think that the usual command does not - the

    Select format from dba_segments where nom_segment = "INFO_MESSAGES" is only showing 7 MB, while I think that the table has several GB of space due to the CLOB.

    Also to add one more detail: when dba_segments seeking, I see a result like this:

    Select * of dba_segments order by bytes DESC;

    MIGRTN SYS_LOB0000111131C00008$ $ LOBSEGMENT SAMS DATA1 20690 6 1963 14528000 119013376000 <-the top row

    MIGRTN this is the schema where this INFO_MESSAGES table is present.

    Thanks,

    OrauserN

    you will need to add the segment_size of the LOB segments to the segment_size of the table. The connection between the two pieces of information you find in USER_LOBS (or the corresponding ALL_, DBA_ objects).

Maybe you are looking for