#1899-DEC-30 00:00:00# converts to to_date('00:00:00', 'HH24:MI:SS')

I'm converting a system from Access to Oracle DB.
Many functions in the system use time ... In Access the time can be referrenced by #00:00:00#. Internally, Access appears to store the time as 1899-DEC-30 00:00:00 (probably stored as number of (milli)seconds from 1899/12/30)
This data happily migrates to the Oracle DB ...
Problem is 'select to_date('00:00:00', 'HH24:MI:SS') from dual' in Oracle results in the first day of the current month of the current year ... for eg 2005-JUL-01 00:00:00 and the data is stored as 1899-DEC-30 00:00:00. So the SQL requests return 0 rows.
How can I work around this?
Note that a call in Access via ODBC to Oracle does the following -
#13:00:00# converts to
to_date('13:00:00', 'HH24:MI:SS')
#1899-DEC-30 13:00:00# converts to
to_date('13:00:00', 'HH24:MI:SS')
#1899-DEC-31 13:00:00# converts to
to_date('1899-12-31 13:00:00','YYYY-MM-DD HH24:MI:SS')

If I enter '09:00:00 PM' into a date/time column on an Access form, the data is stored in the Oracle DB as '30-dec-1899 21:00:00'. This is the same behaviour as Access.
When I select the same row from the table in Access using ...
select * from my_table
where my_column = #21:00:00#
Oracle generates a select statement with the following clause ..
select from my_table
where my_column = to_date('21:00:00', 'HH24:MI:SS')
To demonstrate why this is wrong ==>
select to_date('21:00:00', 'HH24:MI:SS') as my_column from dual
gives
MY_COLUMN
01-jul-2005 21:00:00
So the select statement doesn't retrieve the row.
What Oracle should be doing is converting the #21:00:00# into
to_date('1899-12-30 21:00:00', 'YYYY-MM-DD HH24:MI:SS')

Similar Messages

  • Convert VARCHAR to date in OBIEE

    I have an column Period Name and data as
    DEC-04
    DEC-05
    DEC-07
    I want to convert into date format ..so is there any way...i tried with cast but it through error.
    Thanks,
    S

    hi s,
    Try this out :http://varanasisaichand.blogspot.com/2010/01/how-to-change-data-format-to-our-custom.html
    or use evaluate function
    http://varanasisaichand.blogspot.com/2010/05/evaluate-function.html
    Thanks,
    Saichand.v

  • Convert Varchar2 datatype Date Value To Date Datatype

    Hello,
    I have a date value like the following as varchar2 datatype.
    31-DEC-10 08.40.53 AMI would like to convert this to_date as date datatype.
    How could I do this?

    Use the right format mask?
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions183.htm#SQLRF06132
    SQL> select to_date('31-DEC-10 08.40.53 AM', 'dd-mon-yy hh.mi.ss am')
      2  from  dual;
    TO_DATE('31-DEC-100
    31-12-2010 08:40:53
    1 row selected.
    SQL> declare
      2    dt date;
      3  begin
      4    dt := to_date('31-DEC-10 08.40.53 AM', 'dd-mon-yy hh.mi.ss am');
      5    dbms_output.put_line(to_char(dt, 'dd-mm-yyyy hh24:mi:ss'));
      6  end;
      7  /
    31-12-2010 08:40:53
    PL/SQL procedure successfully completed.

  • Expression Error: Named Object: javax.faces.convert.IntegerConverter not fo

    I get the error below when i try to run the xhtml file.
    May I know how to import the "IntegerConvertor"?
    >
    Expression Error: Named Object: javax.faces.convert.IntegerConverter not found.
    >
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
         <title>Facelet Title</title>
    </h:head>
    <h:body>
    <h:inputText converter="javax.faces.convert.IntegerConverter" />
    </h:body>
    </html>Edited by: anIdiot on 12-Dec-2011 23:52

    <f:converter converterId="javax.faces.Integer"/>

  • Termination Date Service Contracts 12/30/1899

    I have a problem with WT Service Contracts that came from B1. 
    All contracts show a Termination Date of 1899-Dec-30.  I confirmed the TerminationDate Column in the SupportContract table does indeed contain this date.
    Contracts that have a termination date are considered closed. in B1.  Since these contracts are not closed the contract date should be empty.
    I can clear out the TerminationDate Column in the SupportContract Table, but that won't help future contracts that come into WebTools.
    Thanks,
    Jason

    I have passed this to the QA team to verify the bug
    Edited by: Rui Pereira on Dec 29, 2008 6:40 PM

  • 'dd-mm-yyyy hh24:mi:ss ' convertion

    '20061106024500' i want to convert it into 'dd-mm-yyyy hh24:mi:ss format how will i do this.

    This?
    select
    to_char(to_date('20061106024500', 'YYYYMMDDHH24MISS'),'dd-mm-yyyy hh24:mi:ss') new_format from dual

  • Convert Varchar to Hour

    Hi,
    I have a field DATE.
    This item contain a Date. But I have other variable varchar that contain hour (hh:mi:ss).
    I have to convert this varchar to a hour ant concat with the Date Field.
    How can I do this?
    Thankss

    It would help if you posted some simple CREATE TABLE and INSERT statements, so we know what we're dealing with.
    Of what datatype are BOTH your fields?
    Is DATE (bad column name, since DATE is an Oracle reserved word) of DATE datatype or also a VARCHAR2?
    You can turn your VARCHAR2 hour into a DATE hour by using TO_DATE and the correct format:
    SQL> select to_date('01:22:52', 'hh24:mi:ss') from dual;
    TO_DATE('01:22:52',
    01-02-2010 01:22:52

  • Enable Recycle Bin on mapped network drives

    A few years ago I discovered how redirected user profile folders in Windows get Recycle Bin protection, even when the folders are redirected to a network location. This was a huge find for me, and I used this feature to add Recycle Bin coverage to some of
    my mapped network drives. I shared this information on another forum here:
    http://forums.mydigitallife.info/threads/16974-Tip-Network-Recycle-bin
    Today I figured out a better way to achieve the same goal that doesn't rely on user profile folder redirection, and am sharing that information for other users to try out. You might want to take a look at these forum topics for additional information:
    http://technet.microsoft.com/en-us/library/cc787939(v=ws.10).aspx
    http://blogs.technet.com/b/askds/archive/2012/07/16/managing-the-recycle-bin-with-redirected-folders-with-vista-or-windows-7.aspx
    http://msdn.microsoft.com/en-us/library/bb882665.aspx
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/10bfcfb9-14f3-434e-9ffa-0289b8b32e01/folder-redirection-recycle-bin
    The standard disclaimer applies - this might break stuff. I've only tested in Windows 8, and my testing is limited. Try this at your own risk.
    This is what I've learned (or think I've learned - I might be wrong):
    Windows Vista and later store the configuration settings for the Recycle Bin for redirected user profile folders in this registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder
    Under this key are separate keys for each redirected folder that is protected by the Recycle Bin. The keys contain the configuration information for each protected folder, and are named to match the GUIDs for "Known Folders." A list of the Known
    Folder to GUID mappings is available in one of the links above.
    The registry also contains a list of "known folders" at this location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions
    So, I reasoned that if I could create my own custom "known folder," I could add that to the list of folders that were protected by the Recycle Bin and protect any mapped network drive I wanted. So I looked at the list of existing "known folders"
    and created a key that was similar to the Documents key. I then fiddled with the values in the key until I narrowed it down to the minimum number needed to make the recycle bin work.
    This .reg file will protect a mapped X: drive with a ~50GB recycle bin. You should modify the file to fit your needs:
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{9147E464-33A6-48E2-A3C9-361EFD417DEF}]
    "RelativePath"="X:\\"
    "Category"=dword:00000004
    "Name"="XDrive"
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder\{9147E464-33A6-48E2-A3C9-361EFD417DEF}]
    "MaxCapacity"=dword:0000c7eb
    "NukeOnDelete"=dword:00000000
    A few things of note:
    The GUID in the above .reg file {9147E464-33A6-48E2-A3C9-361EFD417DEF} came from this PowerShell command: "{"+[guid]::NewGUID().ToString().ToUpper()+"}"
    Each "known folder"/Recycle Bin combination requires a unique GUID. If you don't want to use PowerShell to generate a GUID, you can use an online GUID generator.
    I don't know what the "Category" value does, but the key I copied had it set to 4, and that works, so I didn't test any other values.
    The "Name" value is required, but is not the name that will be shown if you right-click on the Recycle Bin and select properties. (At least not in my environment.) In my environment, the name that is shown is the name of the network drive.
    Making this change adds a "Location" tab to the properties page of your mapped network drives. I suspect this could be removed by changing the "Category" value, but didn't bother to find out.
    I only tested with mapped network drives. I suspect this would work with UNC paths as well, but I didn't bother testing.
    I hope you're as excited to find this as I was to figure it out. Let me know if this works for you. I now plan to deploy the registry keys with Group Policy Preferences and will update this forum post with any information I discover.
    Best regards
    --Russel
    Update: I am now using Group Policy Preferences to deploy the needed registry keys, and all my mapped network drives are now protected by the recycle bin.
    Update 2: I have tested now with UNC paths, and this works fine. I still use mapped network drives, but if your environment requires UNC paths instead, you can use them. Note however that if you have a mapped network drive that points to a UNC path, and
    you protect the UNC path with a registry change, if a user deletes a file from the mapped network drive that points to that UNC path, the file will be permanently deleted. See below for more details.

    FANTASTIC work Russel !
    This is extremely helpful.
    I've turned your work into a Bat Script that will automatically make the reg file.
    It creates a unique guid each time it is run, so no worries on overlaps.
    Just copy and paste the following into notepad
    and save it as "Network Recycling Bin - auto make registry file.bat"
    echo off
    REM ========== MAIN FUNCTION  ========================
    Call :CreateREGfile
    PAUSE
    goto :eof
    REM ========== SUB FUNCTIONS  ========================
    :CreateREGfile
    set /p RelativePath=Enter
    current mapped path of drive (e.g. X:\FileShare\D_Drive):
    REM replace \ with \\ (for reg value its a requirement)
    Set RelativePath=%RelativePath:\=\\% 
    set /p MaxBinSize_Dec=Enter
    max size (in mb) (eg 11gb=11000):
    call :toHex
    %MaxBinSize_Dec% MaxBinSize_Hex
    Set outputREG="Network
    Recycling Bin - %RelativePath:~0,1% Drive (%MaxBinSize_Dec%mb).reg"
    call :MakeGUID_VBS NewGUID
    REM echo My new GUID : %NewGUID%
    echo Windows Registry Editor Version 5.00
    >
    %outputREG%
    echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\%NewGUID%]
    >>
    %outputREG%
    echo "RelativePath"="%RelativePath%"
    >>
    %outputREG%
    echo "Category"=dword:00000004
    >>
    %outputREG%
    echo "Name"="NetworkDrive2RecyclingBin_%NewGUID:~1,5%"
    >>
    %outputREG%
    REM The "Name" value is required, but is not the name that will be shown if you right-click on the Recycle Bin and select properties. That will be autoset to the network drive name.
    echo.>>
    %outputREG%
    echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder\%NewGUID%] 
    >>
    %outputREG%
    echo "MaxCapacity"=dword:%MaxBinSize_Hex%
    >>
    %outputREG%
    echo "NukeOnDelete"=dword:00000000
    >>
    %outputREG%
    goto :eof
    :MakeGUID_VBS
    echo set obj
    = CreateObject("Scriptlet.TypeLib")
    > TEMP_generateGUID.vbs
    echo WScript.Echo obj.GUID
    >> TEMP_generateGUID.vbs
    FOR /F "usebackq tokens=*"
    %%rin (`CSCRIPT "TEMP_generateGUID.vbs"`)DO
    SET RESULT=%%r
    set
    %1=%RESULT%
    del TEMP_generateGUID.vbs
    goto :eof
    :toDec
    :: todec hex dec -- convert a hexadecimal number to decimal
    ::             -- hex [in]      - hexadecimal number to convert
    ::             -- dec [out,opt] - variable to store the converted decimal number in
    SETLOCAL
    set /a dec=0x%~1
    ( ENDLOCAL & REM RETURN VALUES
        IF "%~2"
    NEQ "" (SET %~2=%dec%)ELSE
    ECHO.%dec%
    EXIT /b
    :toHex
    :: eg  call :toHex dec hex -- convert a decimal number to hexadecimal, i.e. -20 to FFFFFFEC or 26 to 0000001A
    ::             -- dec [in]      - decimal number to convert
    ::             -- hex [out,opt] - variable to store the converted hexadecimal number in
    ::Thanks to 'dbenham' dostips forum users who inspired to improve this function
    :$created 20091203 :$changed 20110330 :$categories Arithmetic,Encoding
    :$source http://www.dostips.com
    SETLOCAL ENABLEDELAYEDEXPANSION
    set /a dec=%~1
    set "hex="
    set "map=0123456789ABCDEF"
    for /L
    %%Nin (1,1,8)do
        set /a "d=dec&15,dec>>=4"
        for
    %%Din (!d!)do
    set "hex=!map:~%%D,1!!hex!"
    rem !!!! REMOVE LEADING ZEROS by activating the next line, e.g. will return 1A instead of 0000001A
    rem for /f "tokens=* delims=0" %%A in ("%hex%") do set "hex=%%A"&if not defined hex set "hex=0"
    ( ENDLOCAL & REM RETURN VALUES
        IF "%~2"
    NEQ "" (SET %~2=%hex%)ELSE
    ECHO.%hex%
    EXIT /b
    :eof

  • Sql query to_date function

    hi all,
    I am working on a project where some sql scripts are already been developed by
    someone else.
    In the code i found
    Select col_name
    from table_name
    where txn_dt between to_date(to_date('05-dec-2007') - 6) and to_date('05-dec-2007');
    I am wondering whats the usage of 2 to_date function in the where clause.
    This can be achieved using this as well:
    Select col_name
    from table_name
    where txn_dt between to_date('05-dec-2007') - 6 and to_date('05-dec-2007');
    Can anybody tell me this diff if there is any?
    Thanks
    Shane

    to_date(to_date('05-dec-2007') - 6)This is an error. Not a syntax error, but a runtime error waiting to happen.
    The inner to_date is fine (except it should have a format mask) but the outer to_date is expecting a character type and it's getting a date. So it has to be converted.
    All this depends on the nls settings which could change.
    Ideally, the code should read:
    Select col_name
    from table_name
    where txn_dt between to_date('05-dec-2007','dd-mon-yyyy') - 6 and to_date('05-dec-2007','dd-mon-yyyy');
    (on second thought...if the nls settings match this date format, it should convert without error in both to_date functions, but still...why do it?)
    Edited by: SomeoneElse on Dec 12, 2008 9:12 AM

  • Dynamic Internal Table - data type changed automatically

    Dear All,
    I have a requirement of craetion of dynamic inetrnal table which I have created referring to a custom table .
    In that custom table there is field ZDC002 of type DEC(16,7) which is converted to data type P(9,7) .
    Now it works fine if 2 digit and 7 decimals  value passed like 12.1234567 but it gives overflow error when passing more than 2 digit value .
    Please help me as I have no control to SAP standard functinality while creation of data-type . My piece of code :
    ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( 'ZBW_EE_DCONTR' ).
          idetails[] = ref_table_des->components[].
    In this idetails[] table filedname data type changed from DEC16,7 to data type P(9,7). => Total Length of Packed Data Type is 9 which allows to contain only 2 numericdigits and 7 decimals => puts overflow error if more than 2 numeric data passed.
    Any suggestions will be appreciated.
    Thanks,
    Sachin

    Did you try to view the code on the Data Source view and cube that it is reflecting the correct data type on both places? if not you can change there and save it.
    prajwal kumar potula

  • Comparing to_date(character) and date(Urgent)

    Hi ,
    I'm having data in one file like this.
    iso_sttl_ref
    DA_DEMO_03082005_03012005-S7
    I'm doing the substring of the above field and I'm converting into date by using to_date function and comparing with a date coming as parameter. but i'm getting an error not a valid month.
    Select distinct (case when ns.ptcpt_cd='DEMO' then substr(iso_sttl_ref,9,8)end)sttl_date,
         trunc(ns.start_dt_gmt)start_dt,ns.sttl_pub_cd,ns.ptcpt_cd,iso_sttl_ref
    from nm_settlement ns, nm_sttl_statement nss
    where ns.statement_id = nss.statement_id
    and trunc (nss.inactive_dt_sys) =to_date ('31-DEC-4000', 'DD-MON-YYYY')
    and to_date(to_number(substr(iso_sttl_ref,9,8)),'mm/dd/yyyy')>=TO_date('10/01/2005','MM/DD/YYYY')
    and to_date(to_number(substr(iso_sttl_ref,9,8)),'mm/dd/yyyy')<=TO_date('10/07/2005','MM/DD/YYYY')
    and ns.source_cd = nvl ('ISO', 'ESTIM')
    and ns.sttl_pub_cd <> 'S7'
    and ns.ptcpt_cd='DEMO'
    and ns.sttl_type_cd='DASTTL'
    order by ns.sttl_pub_cd
    Pls help me out from this problem . your help is greatly appreciated.
    Thanks & Regards,
    Ramana.

    Hi ,
    I'm perfectly getting numerical values no funny character also coming.
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 22 13:06:46 2005
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.5.0 - Production
    SQL> Select distinct (case when ns.ptcpt_cd='DEMO' then to_date(substr(iso_sttl_ref,9,8),'mm/dd/yyy
    y')
    2 when ns.ptcpt_cd='DEMORE' then to_date(substr(iso_sttl_ref,15,8),'mm/dd/yyyy')
    3 end)sttl_date,
    4 trunc(ns.start_dt_gmt)start_dt,ns.sttl_pub_cd,ns.ptcpt_cd,substr(iso_sttl_ref,9,8)
    5 from nm_settlement ns, nm_sttl_statement nss
    6 where ns.statement_id = nss.statement_id
    7 and trunc (nss.inactive_dt_sys) =to_date ('31-DEC-4000', 'DD-MON-YYYY')
    8 --and to_date( substr(iso_sttl_ref,9,8),'mmddyyyy')>=to_date('10/01/2005','MM/DD/YYYY')
    9 --and to_date( substr(iso_sttl_ref,9,8),'mmddyyyy')<=to_date('10/07/2005','MM/DD/YYYY')
    10 and trunc (nss.master_rpt_version_dt_sys) >=TO_DATE('10/01/2005','MM/DD/YYYY')
    11 and trunc (nss.master_rpt_version_dt_sys) <=TO_DATE('10/07/2005','MM/DD/YYYY')
    12 and ns.source_cd = nvl ('ISO', 'ESTIM')
    13 and ns.sttl_pub_cd <> 'S7'
    14 and ns.ptcpt_cd='DEMO'
    15 and ns.sttl_type_cd='DASTTL'
    16 order by ns.sttl_pub_cd
    17 /
    STTL_DATE START_DT STTL_P PTCPT_ SUBSTR(I
    02-OCT-05 30-APR-05 R155 DEMO 10022005
    03-OCT-05 01-MAY-05 R155 DEMO 10032005
    04-OCT-05 02-MAY-05 R155 DEMO 10042005
    05-OCT-05 03-MAY-05 R155 DEMO 10052005
    06-OCT-05 04-MAY-05 R155 DEMO 10062005
    07-OCT-05 05-MAY-05 R155 DEMO 10072005
    08-OCT-05 06-MAY-05 R155 DEMO 10082005
    02-OCT-05 19-JUN-05 S105 DEMO 10022005
    03-OCT-05 20-JUN-05 S105 DEMO 10032005
    04-OCT-05 21-JUN-05 S105 DEMO 10042005
    05-OCT-05 22-JUN-05 S105 DEMO 10052005
    STTL_DATE START_DT STTL_P PTCPT_ SUBSTR(I
    06-OCT-05 23-JUN-05 S105 DEMO 10062005
    07-OCT-05 24-JUN-05 S105 DEMO 10072005
    08-OCT-05 25-JUN-05 S105 DEMO 10082005
    02-OCT-05 18-SEP-05 S14 DEMO 10022005
    03-OCT-05 19-SEP-05 S14 DEMO 10032005
    04-OCT-05 20-SEP-05 S14 DEMO 10042005
    05-OCT-05 21-SEP-05 S14 DEMO 10052005
    06-OCT-05 22-SEP-05 S14 DEMO 10062005
    07-OCT-05 23-SEP-05 S14 DEMO 10072005
    08-OCT-05 24-SEP-05 S14 DEMO 10082005
    02-OCT-05 08-AUG-05 S55 DEMO 10022005
    STTL_DATE START_DT STTL_P PTCPT_ SUBSTR(I
    03-OCT-05 09-AUG-05 S55 DEMO 10032005
    04-OCT-05 10-AUG-05 S55 DEMO 10042005
    05-OCT-05 11-AUG-05 S55 DEMO 10052005
    06-OCT-05 12-AUG-05 S55 DEMO 10062005
    07-OCT-05 13-AUG-05 S55 DEMO 10072005
    08-OCT-05 14-AUG-05 S55 DEMO 10082005
    28 rows selected.

  • Automatic Date Conversion

    Does anyone know of any way to allow an input String representing a date to be converted to a Date object without knowing the format of the date ahead of time? How would any of you handle the case where you want to let users input any date format that Java recognizes (Dec 1, 2001; 12/01/2001; 01-Dec-2001;etc) and automatically convert this to an actual Date object?

    I would use StringTokenizer to pick the single values out of the String, defining the accepted delimiters.
    Each value (token) must be interpreted then. I join the suggestion of generating a collection containing all possible interpretations.
    Finally you have to put the single values together: which interpretations of a single value can be excluded in compare to the other values, which combinations of a complete date stay possible.
    This list must be offered to the user: he has to decide.
    I doubt if it's worth. If you don't mind the work, probably your users will complain, if they are surprised by your list: Why didn't he tell me that how I should put in the date?

  • Query Help pls dates and logic.

    Hi all gurus
    I have a need where I need to put togahter series of timeline events that occurred in past as a one row concerning dates.
    This is my table .
      CREATE TABLE "SORS"."SOR_TRACKING"
       ( "TRACKING_ID" NUMBER NOT NULL ENABLE,
      "LETTER_ID" NUMBER NOT NULL ENABLE,
      "OFFENDER_ID" NUMBER NOT NULL ENABLE,
      "LOCATION_ID" NUMBER NOT NULL ENABLE,
      "OFFICE_ID" NUMBER,
      "MAIL_DATE" DATE DEFAULT SYSDATE NOT NULL ENABLE,
      "RESPONSE_DATE" DATE,
      "STATUS" VARCHAR2(30 BYTE) DEFAULT 'Mailed',
      "ENTRY_DATE" DATE DEFAULT SYSDATE NOT NULL ENABLE,
      "ENTRY_USER" VARCHAR2(30 BYTE) NOT NULL ENABLE,
      "COMMENTS" VARCHAR2(2000 BYTE),
      "FIRST_NAME" VARCHAR2(80 BYTE) NOT NULL ENABLE,
      "MIDDLE_NAME" VARCHAR2(80 BYTE),
      "LAST_NAME" VARCHAR2(80 BYTE) NOT NULL ENABLE,
      "SIR_NAME" VARCHAR2(30 BYTE),
      "ADDRESS1" VARCHAR2(80 BYTE),
      "ADDRESS2" VARCHAR2(80 BYTE),
      "CITY" VARCHAR2(50 BYTE),
      "STATE" VARCHAR2(30 BYTE),
      "ZIP" VARCHAR2(20 BYTE),
      "COUNTY" VARCHAR2(80 BYTE),
      "OFFENDER_TYPE" VARCHAR2(30 BYTE),
      "LAST_MAIL_DATE" DATE,
      "BATCH_ID" NUMBER NOT NULL ENABLE,
      "JURISDICTION" NUMBER,
      "DL_NAME" VARCHAR2(60 BYTE),
      "DL_OFFICE" VARCHAR2(60 BYTE),
      "DL_ADDRESS" VARCHAR2(60 BYTE),
      "DL_MAILING_ADDRESS" VARCHAR2(60 BYTE),
      "DL_CITY" VARCHAR2(60 BYTE),
      "DL_STATE" VARCHAR2(30 BYTE),
      "DL_ZIP" VARCHAR2(20 BYTE),
      "TITLE" VARCHAR2(10 BYTE),
      "MODIFIED_USER" VARCHAR2(30 BYTE),
      "MODIFIED_DATE" DATE,
      CONSTRAINT "PK_SOR_TRACKING" PRIMARY KEY ("TRACKING_ID"))
    Sample date
    REM INSERTING into SOR_TRACKING
    SET DEFINE OFF;
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (781410,1,4557,110207,2809,to_date('05-NOV-13','DD-MON-RR'),null,'Mailed',to_date('05-NOV-13','DD-MON-RR'),'NEEL',null,'BOB','Jolene','Luna',null,'20535 Valleyview Rd ',null,'Boo','OK','74840','potter','STANDARD',to_date('15-FEB-12','DD-MON-RR'),30211,2809,null,null,null,null,null,null,null,'Ms.','NEEL',to_date('05-NOV-13','DD-MON-RR'));
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (190294,1,4557,110207,2809,to_date('08-FEB-12','DD-MON-RR'),to_date('15-FEB-12','DD-MON-RR'),'Verified',to_date('17-FEB-12','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'20535 Valleyview Rd ',null,'Boo','OK','74840','potter','STANDARD',to_date('13-DEC-11','DD-MON-RR'),28442,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (184647,1,4557,110207,2809,to_date('05-DEC-11','DD-MON-RR'),to_date('13-DEC-11','DD-MON-RR'),'Verified',to_date('15-DEC-11','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'20535 Valleyview Rd ',null,'Boo','OK','74840','potter','STANDARD',to_date('09-NOV-11','DD-MON-RR'),27985,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (157253,1,4557,102288,2809,to_date('03-FEB-11','DD-MON-RR'),null,'Mailed',to_date('03-FEB-11','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('08-NOV-10','DD-MON-RR'),25613,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (149710,1,4557,102288,2809,to_date('01-NOV-10','DD-MON-RR'),to_date('08-NOV-10','DD-MON-RR'),'Verified',to_date('16-NOV-10','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('18-OCT-10','DD-MON-RR'),24939,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (138268,1,4557,99564,2809,to_date('03-JUN-10','DD-MON-RR'),to_date('17-JUN-10','DD-MON-RR'),'Letter Returned',to_date('17-JUN-10','DD-MON-RR'),'Boo','Post office: No mail receptacle','BOB','Jolene','Luna',null,'20535 Valley View Rd.',null,'Boo','OK','74840','potter','STANDARD',to_date('19-MAY-10','DD-MON-RR'),24216,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (128798,1,4557,91503,2809,to_date('04-FEB-10','DD-MON-RR'),null,'Mailed',to_date('04-FEB-10','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('10-NOV-09','DD-MON-RR'),23369,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (115073,1,4557,91503,2809,to_date('07-AUG-09','DD-MON-RR'),to_date('10-NOV-09','DD-MON-RR'),'Verified',to_date('10-NOV-09','DD-MON-RR'),'Boo',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('06-MAY-09','DD-MON-RR'),21926,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (108510,1,4557,91503,2809,to_date('05-MAY-09','DD-MON-RR'),to_date('06-MAY-09','DD-MON-RR'),'Verified',to_date('07-MAY-09','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('01-MAY-09','DD-MON-RR'),21316,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (101463,1,4557,88052,2809,to_date('05-FEB-09','DD-MON-RR'),null,'Mailed',to_date('05-FEB-09','DD-MON-RR'),'Boo',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('15-DEC-08','DD-MON-RR'),20525,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (97272,1,4557,88052,2809,to_date('05-DEC-08','DD-MON-RR'),to_date('15-DEC-08','DD-MON-RR'),'Verified',to_date('17-DEC-08','DD-MON-RR'),'Casper',null,'BOB','Jolene','Luna',null,'PO Box 146',null,'Boo','OK','74840','potter','STANDARD',to_date('12-NOV-08','DD-MON-RR'),20018,2809,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (68398,1,4557,76399,1070,to_date('10-OCT-07','DD-MON-RR'),to_date('15-NOV-07','DD-MON-RR'),'Letter Returned',to_date('15-NOV-07','DD-MON-RR'),'KERRYMIN','post office: not delivaerable as addressed ','BOB','Jolene','Luna',null,'752 Boo',null,'Norman','OK','73072','Cleveland','STANDARD',to_date('17-MAY-07','DD-MON-RR'),16596,1070,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (63767,1,4557,76399,1070,to_date('09-AUG-07','DD-MON-RR'),to_date('20-AUG-07','DD-MON-RR'),'Letter Returned',to_date('20-AUG-07','DD-MON-RR'),'KERRYMIN','post office: not deliverable as addressed ','BOB','Jolene','Luna',null,'752 Boo',null,'Norman','OK','73072','Cleveland','STANDARD',to_date('17-MAY-07','DD-MON-RR'),16077,1070,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (59499,1,4557,76399,1070,to_date('14-MAY-07','DD-MON-RR'),to_date('17-MAY-07','DD-MON-RR'),'Verified',to_date('17-MAY-07','DD-MON-RR'),'LAWANHAM',null,'BOB','Jolene','Luna',null,'752 Boo',null,'Norman','OK','73072','Cleveland','STANDARD',to_date('14-MAY-07','DD-MON-RR'),15569,1070,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (54783,1,4557,74693,1070,to_date('01-MAR-07','DD-MON-RR'),to_date('06-MAR-07','DD-MON-RR'),'Verified',to_date('13-MAR-07','DD-MON-RR'),'Boo',null,'BOB','Jolene','Luna',null,'1203 Rebecca Lane',null,'Norman','OK','73072','Cleveland','STANDARD',to_date('01-MAR-07','DD-MON-RR'),14994,1070,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (34100,1,4557,58761,1094,to_date('08-FEB-06','DD-MON-RR'),null,'Mailed',to_date('31-MAR-06','DD-MON-RR'),'LAWANHAM','per M. Splawn','BOB','Jolene','Luna',null,'Rt. 1 Box 42',null,'Wewoka','OK','74884','Seminole','STANDARD',to_date('03-FEB-06','DD-MON-RR'),9560,1094,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (27562,1,4557,52781,1115,to_date('08-NOV-05','DD-MON-RR'),null,'Mailed',to_date('08-NOV-05','DD-MON-RR'),'Boo',null,'BOB','Jolene','Luna',null,'5590 Rebel Ridge Rd',null,'El Reno','OK','73036','Canadian','STANDARD',to_date('16-OCT-05','DD-MON-RR'),8034,1115,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (11822,1,4557,39238,1094,to_date('03-MAR-05','DD-MON-RR'),null,'Mailed',to_date('03-MAR-05','DD-MON-RR'),'Boo',null,'BOB','Jolene','Luna',null,'Rt. 1, Box 42',null,'Wewoka','OK','74884','Seminole','STANDARD',to_date('17-FEB-05','DD-MON-RR'),306,null,null,null,null,null,null,null,null,'Ms.',null,null);
    Insert into SOR_TRACKING (TRACKING_ID,LETTER_ID,OFFENDER_ID,LOCATION_ID,OFFICE_ID,MAIL_DATE,RESPONSE_DATE,STATUS,ENTRY_DATE,ENTRY_USER,COMMENTS,FIRST_NAME,MIDDLE_NAME,LAST_NAME,SIR_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTY,OFFENDER_TYPE,LAST_MAIL_DATE,BATCH_ID,JURISDICTION,DL_NAME,DL_OFFICE,DL_ADDRESS,DL_MAILING_ADDRESS,DL_CITY,DL_STATE,DL_ZIP,TITLE,MODIFIED_USER,MODIFIED_DATE) values (2257,1,4557,18958,1087,to_date('03-AUG-04','DD-MON-RR'),null,'Mailed',to_date('29-JAN-05','DD-MON-RR'),'SYSTEM',null,'BOB','Jolene','Luna',null,'1037 Tabor Drive',null,'Oklahoma City','OK','73107','Oklahoma',null,null,178,null,null,null,null,null,null,null,null,null,null,null);
    I want to find the all the records whose mail date(earliest of all with no reply) and no response date and find the earlier one with reponse date and display it as a one row.
    For example 
    mail_Date+45 mail_Date in table    earliest date of reponse
    BEGIN_DATE   DEL_DATES           END_DATE                 TRACKING_ID
    17-SEP-04    03-AUG-04 06-          MAR-07                                2257
    Other date and their response date should be shown same way
    The issue is I am not able to retrieve other records in the tables because I am using MIN function.
    here is my query
    SELECT   t.MAIL_DATE + 45 begin_Date,
      del_date.del_dates,
      (SELECT MIN(st2.RESPONSE_DATE) Del_end_date
      FROM sor_tracking st2
      WHERE t.OFFENDER_ID   = st2.OFFENDER_ID
      AND st2.RESPONSE_DATE > del_date.del_dates
      ) End_date,
      t.OFFENDER_ID,
      t.TRACKING_ID
    FROM
      (SELECT MIN(st1.MAIL_DATE) del_dates
        FROM sor_tracking st1
      WHERE st1.OFFENDER_ID  = 4557
      AND st1.RESPONSE_DATE IS NULL
      AND st1.MAIL_DATE      < SysDate - 45
      AND st1.STATUS                  IN ('Letter Returned', 'Mailed')
      AND st1.LETTER_ID               IN (1, 4)
      ) del_date,
      sor_tracking t
    WHERE t.MAIL_DATE   <= del_date.del_dates
    AND (t.OFFENDER_ID   = 4557
         AND t.RESPONSE_DATE IS NULL)
    ORDER BY 1 desc
    Thanks for you time and help.

    with
    sor_tracking as
    (select 4557 offender_id,
            1 letter_id,
            to_date('05-NOV-13','dd-MON-yy') mail_date,
            781410 tracking_id,
            110207 location_id,
            null response_date,
            'Mailed' status
       from dual
    union all
    select 4557,1,to_date('08-FEB-12','dd-MON-yy'),190294,110207,to_date('15-FEB-12','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('05-DEC-11','dd-MON-yy'),184647,110207,to_date('13-DEC-11','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('03-FEB-11','dd-MON-yy'),157253,102288,null,'Mailed' from dual union all
    select 4557,1,to_date('01-NOV-10','dd-MON-yy'),149710,102288,to_date('08-NOV-10','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('03-JUN-10','dd-MON-yy'),138268,99564,to_date('17-JUN-10','dd-MON-yy'),'Letter Returned' from dual union all
    select 4557,1,to_date('04-FEB-10','dd-MON-yy'),128798,91503,null,'Mailed' from dual union all
    select 4557,1,to_date('07-AUG-09','dd-MON-yy'),115073,91503,to_date('10-NOV-09','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('05-MAY-09','dd-MON-yy'),108510,91503,to_date('06-MAY-09','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('05-FEB-09','dd-MON-yy'),101463,88052,null,'Mailed' from dual union all
    select 4557,1,to_date('05-DEC-08','dd-MON-yy'),97272,88052,to_date('15-DEC-08','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('10-OCT-07','dd-MON-yy'),68398,76399,to_date('15-NOV-07','dd-MON-yy'),'Letter Returned' from dual union all
    select 4557,1,to_date('09-AUG-07','dd-MON-yy'),63767,76399,to_date('20-AUG-07','dd-MON-yy'),'Letter Returned' from dual union all
    select 4557,1,to_date('14-MAY-07','dd-MON-yy'),59499,76399,to_date('17-MAY-07','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('01-MAR-07','dd-MON-yy'),54783,74693,to_date('06-MAR-07','dd-MON-yy'),'Verified' from dual union all
    select 4557,1,to_date('08-FEB-06','dd-MON-yy'),34100,58761,null,'Mailed' from dual union all
    select 4557,1,to_date('08-NOV-05','dd-MON-yy'),27562,52781,null,'Mailed' from dual union all
    select 4557,1,to_date('03-MAR-05','dd-MON-yy'),11822,39238,null,'Mailed' from dual union all
    select 4557,1,to_date('03-AUG-04','dd-MON-yy'),2257,18958,null,'Mailed' from dual
    select offender_id,
           letter_id,
           to_char(event_date,'dd-MON-yy') mail_date,
           tracking_id,
           location_id,
           case when last_response_verified is null
                then status
           end status,
           to_char(last_response_verified,'dd-MON-yy') response_date,
           case when last_response_verified is not null
                then 'Verified'
           end response_status
      from (select offender_id,
                   letter_id,
                   event_date,
                   tracking_id,
                   location_id,
                   status,
                   to_find,
                   verified_response,
                   last_value(verified_response ignore nulls) over (partition by offender_id,letter_id
                                                                        order by event_date desc
                                                                   ) last_response_verified
              from (select offender_id,
                           letter_id,
                           event_date,
                           tracking_id,
                           location_id,
                           status,
                           case when event_date < lead(event_date) over (partition by offender_id,letter_id,tracking_id
                                                                             order by event_date
                                                                        ) - 45
                                then 'THIS'
                                when status = 'Mailed'
                                 and lead(tracking_id) over (partition by offender_id,letter_id,tracking_id
                                                                 order by event_date
                                                            ) is null
                                 and direction != lag(direction,1,'null') over (partition by offender_id,letter_id
                                                                                    order by event_date
                                then 'this'
                           end to_find,
                           case when status = 'Verified'
                                then event_date
                           end verified_response
                      from (select offender_id,
                                   letter_id,
                                   mail_date event_date,
                                   tracking_id,
                                   location_id,
                                   'Mailed' status,
                                   'sent' direction
                              from sor_tracking
                            union all
                            select offender_id,
                                   letter_id,
                                   response_date,
                                   tracking_id,
                                   location_id,
                                   status,
                                   'rcvd' direction
                              from sor_tracking
                             where response_date is not null
    where to_find is not null
    order by event_date desc
    OFFENDER_ID
    LETTER_ID
    MAIL_DATE
    TRACKING_ID
    LOCATION_ID
    STATUS
    RESPONSE_DATE
    RESPONSE_STATUS
    4557
    1
    05-NOV-13
    781410
    110207
    Mailed
    4557
    1
    03-FEB-11
    157253
    102288
    13-DEC-11
    Verified
    4557
    1
    04-FEB-10
    128798
    91503
    08-NOV-10
    Verified
    4557
    1
    07-AUG-09
    115073
    91503
    10-NOV-09
    Verified
    4557
    1
    05-FEB-09
    101463
    88052
    06-MAY-09
    Verified
    4557
    1
    03-AUG-04
    2257
    18958
    06-MAR-07
    Verified
    Regards
    Etbin

  • Date range query  problem  in report

    Hi all,
    I have created a report based on query and i want to put date range selection but query giving problem.
    If i am creating select list selection then it is working fine means it will display all records on the particular date.
    But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
    Here is the query:
    /* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
    SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
    tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
    tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
    tsh."STATUS"
    FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
    WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
    AND (tsh.machine_type LIKE :p23_machine_type_sp)
    AND ( tsh.machine_serial_number LIKE
    TO_CHAR (:p23_machine_serial_number_sp)
    OR tsh.machine_serial_number IS NULL
    AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
    TO_CHAR (:p23_failure_date_sp)
    OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
    AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
    BETWEEN TO_CHAR (:p23_creation_date_sp)
    AND TO_CHAR (:p23_creation_date_sp1)
    OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
    AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
    AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
    AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
    OR tsh.local_report_number IS NULL
    AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
    OR tsp.part_number IS NULL
    AND tsh.machine_type IN (
    SELECT DISTINCT machine_type
    FROM trx_sales_dept_machine_list
    WHERE sales_department_id IN (
    SELECT DISTINCT sales_department_id
    FROM trx_user_sales_department
    WHERE UPPER (user_name) =
    UPPER ('&APP_USER.'))
    AND SYSDATE >= valid_from)
    AND tsh.sr_header_id = tsp.sr_header_id
    can any one tell me wat is wroung in this query.
    Any other way to write this?
    Thank You,
    Amit

    Hi User....
    Here is some date range SQL that my teams uses with some success:
    For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
    The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
    AND TRUNC(DATE_IN_DATABASE)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),:
    :P1_DATE_TO)
    For date columns that contain NULL values, try this (a little bit trickier):
    AND nvl(TRUNC(DATE_IN_DATABASE),
    decode( :P1_DATE_FROM,
    decode( :P1_DATE_TO,
    TO_DATE('30-DEC-3000'),
    NULL),
    NULL)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),
    :P1_DATE_TO)
    Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
    I hope this helps.
    By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
    find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
    Cheers,
    Patrick

  • SQL Error while running......

    Hello all,
    I am using R12.1.3.
    I have ran the insert query in GL_interface Table from my client system. I have attached the Insert query as below.
    insert into GL_INTERFACE (
    STATUS, LEDGER_ID, REFERENCE1, REFERENCE4, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME,
    ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5,
    ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID
    values
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 1000.00, 0.00, 1122),
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 500.00, 0.00, 1122),
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '000', '1110', '0000', '000', 'A', 1500.00, 0.00, 1122);
    While running the above query, its giving the below error in SQL Developer.
    An error was encountered performing the requested operation:
    ORA-00933: SQL command not properly ended
    *00933.00000 - "SQL command not properly ended"*
    **Cause:*
    **Action:*
    Vendor code 933Error at line:8 Column:215
    Please guide me what could be the issue.
    Thanks and Regards,
    Muthukumar
    [email protected]

    Muthu wrote:
    Hello all,
    I am using R12.1.3.
    I have ran the insert query in GL_interface Table from my client system. I have attached the Insert query as below.
    insert into GL_INTERFACE (
    STATUS, LEDGER_ID, REFERENCE1, REFERENCE4, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME,
    ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5,
    ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID
    values
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 1000.00, 0.00, 1122),
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 500.00, 0.00, 1122),
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '000', '1110', '0000', '000', 'A', 1500.00, 0.00, 1122);
    While running the above query, its giving the below error in SQL Developer.
    An error was encountered performing the requested operation:
    ORA-00933: SQL command not properly ended
    *00933.00000 - "SQL command not properly ended"*
    **Cause:*
    **Action:*
    Vendor code 933Error at line:8 Column:215
    Please guide me what could be the issue.
    Thanks and Regards,
    Muthukumar
    [email protected]
    Change the above to the following:
    SQL> insert into GL_INTERFACE (
    STATUS, LEDGER_ID, REFERENCE1, REFERENCE4, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME,
    ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5,
    ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID)
    values
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 1000.00, 0.00, 1122);
    insert into GL_INTERFACE (
    STATUS, LEDGER_ID, REFERENCE1, REFERENCE4, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME,
    ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5,
    ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID)
    values
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '830', '5300', '0000', '000', 'A', 500.00, 0.00, 1122);
    insert into GL_INTERFACE (
    STATUS, LEDGER_ID, REFERENCE1, REFERENCE4, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME,
    ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5,
    ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID)
    values
    ( 'NEW', 1, 'TEST_Batch2','TEST_Journal2', 'Payroll', 'Payroll', to_date('DEC-22-2008','MON-DD-YYYY'), 'USD', to_date('DEC-23-2008','MON-DD-YYYY'), 1092, '01', '000', '1110', '0000', '000', 'A', 1500.00, 0.00, 1122);Thanks,
    Hussein

Maybe you are looking for

  • How can I save the preferences in Adobe Acrobat Standard XI?

    Hello, I'm not able to save any preferences in Acrobat. (like Units, display preferences, the locations of the tools...) Each time I exit and open again Acrobat, the preferences are not saved, which is very annoying Kind regards, Nicolas

  • .Mac Web Gallery crashes Safari

    I am replacing our old iWeb photo pages with a .Mac Web Gallery. I've got 63 Albums that I've turned into galleries. When I try to load the main gallery page I get this error from Safari: *A script on the page ".Mac Web Gallery -" ( http://gallery.ma

  • SEM CPM - Dump when i tried to assign a variable

    Hi Gurus, Im working with SEM-CPM and i facing the following issue: When i tried to assign a CPM variable in design mode it show up the following DUMP (during the preview of the Frame) : "MESSAGE_TYPE_X" C- "ADD_DATA_TO_BUFFER" Does anybody knows how

  • Field order and frame rate for motion graphic

    Hi all, I'm creating a some graphics to project on big screen LED for live concert & later the editor might use these graphics in his ntsc 16x9 29.97fps digibeta source cut so which is the best way? 1- 853x486 square pixel, progressive, 29.97fps 2- 8

  • My i phone is locked i cannot input my code

    Hello Support Community, after activating the speakcontrole. I cannot input my code anymore. You can see the numbers when you touch them nothing happens. Permanently a voice is talking to me! I already made a restart and reset. Unfortunately the SIM