Find the date max and then perform a calculation.

Hello

I have two tables. CC Cla_case and this Cla_event. The join between the two tables is on cc.cla_event_no = ce.cla_event_no.
In cla_case, I have the following columns: Discover_date and Notification_date. Cla_event I have the Incident_date column.

I need to perform a subquery that is the last (most recent) date, what cc comparison. Discover_date and this. Incident_date. Once he did that I then have to subtract this recording of cc. Notification_date to find out how many DAYS was held until the incident has been reported.

My date format is as follows: 16 April 2008 07.50
Once more, I need only DAYS between Notification and last date between Discover and Incident.

Thank you very much!

Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

Hello

It is always useful to post some build instructions in the table and a small set of data to work with an example of your desired output. In this case, as I understand it, I don't think that you need a subquery - instead, you just use the LARGEST function...

WITH cla_case AS
(     SELECT 1 event_no, to_date('01/10/2011','dd/mm/yyyy') discover_date, to_date('02/10/2011','dd/mm/yyyy') notification_date from dual union all
     SELECT 2 event_no, to_date('02/10/2011','dd/mm/yyyy') discover_date, to_date('03/10/2011','dd/mm/yyyy') notification_date from dual union all
     SELECT 3 event_no, to_date('03/10/2011','dd/mm/yyyy') discover_date, to_date('04/10/2011','dd/mm/yyyy') notification_date from dual
),
cla_event AS
(     SELECT 1 event_no, to_date('02/10/2011','dd/mm/yyyy') incident_date from dual union all
     SELECT 2 event_no, to_date('02/10/2011','dd/mm/yyyy') incident_date from dual union all
     SELECT 3 event_no, to_date('03/10/2011','dd/mm/yyyy') incident_date from dual
)
SELECT
    cc.event_no,
    cc.discover_date,
    cc.notification_date,
    ce.incident_date,
     cc.notification_date - GREATEST(cc.discover_date,ce.incident_date)
FROM
     cla_case cc,
     cla_event ce
WHERE
     cc.event_no = ce.event_no
/
  EVENT_NO DISCOVER_DATE        NOTIFICATION_DATE    INCIDENT_DATE              DIFF
---------- -------------------- -------------------- -------------------- ----------
         1 01-OCT-2011 00:00:00 02-OCT-2011 00:00:00 02-OCT-2011 00:00:00          0
         2 02-OCT-2011 00:00:00 03-OCT-2011 00:00:00 02-OCT-2011 00:00:00          1
         3 03-OCT-2011 00:00:00 04-OCT-2011 00:00:00 03-OCT-2011 00:00:00          1

3 rows selected.

Elapsed: 00:00:00.03

HTH

David

Tags: Database

Similar Questions

  • How to find the value max and min for each column in a table 2d?

    How to find the value max and min for each column in a table 2d?

    For example, in the table max/min for the first three columns would be 45/23, 14/10, 80/67.

    Thank you

    Chuck,

    With color on your bars, you should have enough experience to understand this.

    You're a loop in the table already.  Now you just need a function like table Max and min. loop.  And you may need to transpose the table 2D.

  • How to find the value max and min of an attribute for a master VO

    Hello
    Is it possible to find maximum and minimum a master view object attribute values in groovy.
    I need to have the (START_DATE) min and max (end_date), values to pass to my Gantt chart to the table project start date and end date.
    For detail view objects, we can use < accessor > .max (start_date), but to see Master objects?

    I use jdeveloper 11.1.1.3.

    Thank you
    Guna.

    Published by: guna.b on December 13, 2010 11:01

    How about setting GOES to the same point of view and by using the groovy you mentioned in your message

  • Search for a string in the data merge, and then change the font color

    I'm working on an invitation from style postcard with the addresses overleaf. So far, I got the invitation and the mail-side with a fusion of data model to a CSV file successfully. Now, as part of my design, I want all the s of the letter 'b' on the model of mail-side (data fusion) of yellow color. The use of JavaScript is it possible? That's what I have so far, but something is wrong:

    app.findTextPrefences = NothingEnum.NOTHING as FindTextPreference;

    app.changeTextPrefences = NothingEnum.NOTHING as ChangeTextPreference;

    var myColor:Color = myDocument.colors.add ();

    myColor.model = ColorModel.PROCESS;

    myColor.space = ColorSpace.CMYK;

    myColor.colorValue = [0, 0, 100, 16];

    app.findChangeTextOptions.caseSensitive = false;

    app.findChangeTextOptions.includeFootnotes = false;

    app.findChangeTextOptions.includeHiddenLayers = false;

    app.findChangeTextOptions.includeLockedLayersForFind = false;

    app.findChangeTextOptions.includeLockedStoriesForFind = false;

    app.findChangeTextOptions.includeMasterPages = false;

    app.findChangeTextOptions.wholeWord = false;

    app.findTextPrefences.findWhat = 'b ';.

    app.changeTextPrefences.fillColor = myColor;

    app.findTextPrefences = NothingEnum.NOTHING as FindTextPreference;

    app.changeTextPrefences = NothingEnum.NOTHING as ChangeTextPreference;

    Hello

    After you set the preferences you must call the changeText() method, as

    myDoc.changeText ();

    or

    myStory.changeText ();

    But it is a static solution.

    You can use a dynamic solution to define a good characterStyle and take advantage of the nestedGrepStyle style applied to this part of your design.

    For each character 'b' could be applied with your characterStyle automatically, no need to run a script.

    Jarek

  • Dynamics Processor Calc does not reach more than [100] ESM blocks during the calculation, please increase the CalcLockBlock setting, and then try again (a small data cache setting can also cause this problem, check the size of data cache setting).

    Hello

    Our environment is Essbase 11.1.2.2 and work on Essbase EAS and components of Shared Services. One of our user tried to execute the Script of Cal of a single application and in the face of this error.

    Dynamics Processor Calc does not reach more than [100] ESM blocks during the calculation, please increase the CalcLockBlock setting, and then try again (a small data cache setting can also cause this problem, check the size of data cache setting).


    I did a few Google and found that we need to add something in the Essbase.cfg file as below.

    Dynamics Processor Calc 1012704 fails to more blocks ESM number for the calculation, please increase the CalcLockBlock setting, and then try again (a small data cache setting can also cause this problem, check the size of data cache setting).

    Possible problems

    Analytical services cannot lock enough blocks to perform the calculation.

    Possible solutions

    Increase the number of blocks of analytical Services can allocate to a calculation:

    1. Set the maximum number of blocks of analytical Services can allocate at least 500.
      1. If you are not a $ARBORPATH/bin/essbase.cfg on the file server computer, create one using a text editor.
      2. In the essbase.cfg folder on the server computer, set CALCLOCKBLOCKHIGH to 500.
      3. Stopping and restarting Analysis server.
    2. Add the command SET LOCKBLOCK STUDENT at the beginning of the calculation script.
    3. Set the cache of data large enough to hold all the blocks specified in the CALCLOCKBLOCKHIGH parameter.

    In fact in our queue (essbase.cfg) Config Server we have given below added.

    CalcLockBlockHigh 2000

    CalcLockBlockDefault 200

    CalcLockBlocklow 50


    So my question is if edit us the file Essbase.cfg and add the above settings restart services will work?  and if yes, why should change us the configuration file of server if the problem concerns a Cal Script application. Please guide me how to do this.


    Kind regards

    Naveen

    Yes it must *.

    Make sure that you have "migrated settings cache of database as well. If the cache is too small, you will have similar problems.

  • Toshiba 40TL938G - find the date and time settings

    I have a 40TL938G and I can't find the date and time settings.
    Can someone help me?

    SSY
    I read the manual and it does ' t say anything about these settings.

    THX

    In the settings of digital television, you should see the option called local time settings

    To display the time on the TV you press the sign of the small clock on the remote control while watching a normal TV show (analog only)

  • I have a PC brand new - HP and played Chess Titans. Now all of a sudden it says it cannot find the texture, but he said no zero the reference count and then could not find device 3D.

    original title: Chess Titans

    I have a PC brand new - HP and played Chess Titans.  Now all of a sudden it says it cannot find the texture, but he said no zero the reference count and then could not find device 3D.  What's past and how to fix this.  Thank you.

    These error messages can occur if you (or software) also disabled Aero. Aero must be on (and supported by the video card) to play Chess Titans. "192GO should be enough for everyone." (of the miniseries "Next generation jokes")

  • Windows cannot find C:\WINDOWS\system32\rundll.exe. Make sure you typed the name correstly and then try again. To search for a file check the Start button and then click search.

    I tried to launch my Spysweeper and found that is not there, then I re downloaded and I could not install it because it was already on my computer.  I went to the control panel to remove and got the message:

    Windows cannot find C:\WINDOWS\system32\rundll32.exe.  Make sure you typed the name correctly and then try again.  To search for a file, select the Start button and then check the search...

    What should I do?

    Hi gsrow,

    You can go there!

    Cannot find the Rundll32.exe file when you open the control panel:
    http://support.Microsoft.com/kb/812340

    Alternatively, copy the folder C:\Windows\System32\DllCache Rundll32.exe file to the System32 folder. Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • Error: Windows cannot find "C:\Program Files\Common Files\LogiShrd\CDDRV3\LDConfig.exe." Make sure that you type the name correctly, and then try again at the start of Windows 7.

    Original title: Windows cannot find "C:\Program Files\Common Files\LogiShrd\CDDRV3\LDConfig.exe." Make sure that you type the name correctly, and then try again.

    This error keeps showing up in when I connect to my pc. How am I able to fix this? It's really annoying. Please help me.

    Its a file/utility Logitech and nothing to do with the victory

  • Windows cannot find "c:/program files/.../programm.exe." "Make sure you typed the name correctly and then try again", I cannot run programms like Admin, what to do?

    I have a problem at the opening of the software as administrator, whenever I open a programm (programs that require admin privaleges) says "windows cannot find" C:/Program Files/.../program.exe". Make sure you typed the name correctly and then try again. "(THIS HAPPENS FOR EACH PROGRAM) I am the only user, also, I am the administrator, I also have another problem, when I run the control panel and try to change something it will not open the box (I wanted to know if the parameters are wrong), when I click, it is as I have not clicked at all, even in SafeMode im helpless There, I can't even change my account settings and run sys restore, but I can open the program (I scanned it are malwares and viruses, but nothing was found, my computer is clean), pls help me, any advice would be very appricieated. I defragmented, managed antivirus analysis I did everything. I've used software: advanced system care, safety 2012 AVG, Malwarebytes anti-malware trial. Sometimes, when I want to uninstall something safe mode (only there, I can do something) I get the message that im not allowed to uninstall the software.

    Still having the problem? Were you able to run SFC in Mode safe?

    You could try a repair of Windows 7 installation or if not a clean install.

  • Convert the Period_Name in GL_JE_Lines table to a date format and then come back year

    I'm working on a data model BI Publisher and I try to convert the Period_Name in GL_JE_Lines table to a date format and then return of the year.

    The sql below works in 11i, but I can't make it work in Fusion.

    to_char (to_date (l. )) period_name , ' MON-RR ' ),'YYYY')

    Any ideas?

    Hi Jennifer,.

    To_char (sysdate, 'DDMONYYYY') in BI Publisher does not return a correct results due NLS_DATE_FORMAT/DATE_LANGUAGE settings.

    According to the standards of the I18N, NLS_DATE_LANGUAGE in the database is still hardcoded to NUMERIC_DATE_LANGUAGE. NUMERIC_DATE_LANGUAGE 'MY' in a date format mask is an integer, so you see the correct value.

    You're not supposed to publish direct SQL with fixΘe format masks (unless it's some sort of canonical format used in internal processing, including the end-user will not be), you should return language digital date to the mid range and then make the formatting of y.

    Workaround

    Try adjusting the NLS_LANGUAGE in SQL data model to override formatting from of the

    Data base and values of the Session, for ex: select to_char (sysdate, 'MON-DD-YYYY', 'NLS_DATE_LANGUAGE = AMERICAN') of double;

    I got this Oracle support after lifting a SR.

    Thank you

    Rahul.

  • How to fix "windows cannot find ' ms-windows-store: purge cache, make sure you typed the name correctly, and then try again.

    I got an error message saying "windows cannot find ' ms-windows-store: purging caches, make sure that you have typed the name correctly and then try again. I have no idea what it means. Help, please.

    Reach
    CTRL X

    Bring up the Windows powershell admin

    Type the following text
    PowerShell - ExecutionPolicy Unrestricted Add-AppxPackage - registry DisableDevelopmentMode-$Env:SystemRoot\WinStore\AppxManifest.xml

    Return to the windows store and it should re - work!

    Congratulations to Luis Cantero of this post http://answers.microsoft.com/en-us/windows/forum/windows8_1-windows_store/just-updated-to-windows-81-and-the-windows-store/c4cf204d-bd99-426c-b800-9c9125ae739c?page=2

    Enjoy

    Yahya Al - Din

  • Migration of virtual machines from a data store, and then delete the data store?

    Hello

    I have a future deployment this month and my Director wants to build a new RAID 6 array, create a store of data with the new table and then move all the VMS to the newly created data store.

    Then he asked me to take the old data store and remove it and the available space between the deleted data store and other stores of data in our shared environment. The question is when the new raid is created and vm has migrated to the new data store, which is the best way to remove the data store empty and make sure that the space available for other data stores? Any help would be appreciated...

    Greg ~.

    If all controls are met, you can go ahead and take it apart without any problem.

    I have re-iterate below checks:

    -No virtual machine is in the data store

    -The data store is not part of the cluster data store

    -The data store is not managed by the DRS storage

    -IGCS is disabled for this data store

    -The data store is not used for vSphere HA heartbeat.

    Especially highlighted 2 controls. Please note that SIOC can be enabled on the data without SDR photo store

  • 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.

  • where do you find the date of purchase on your computer

    Im trying to upgrade to windows 7, but it asked for the date of the purchase I don't have reception more and then I try again, it said that it is inelegible because he already has my serial number

    Hello Jonesejeans,

    Thanks for posting on the Community Forums of Microsoft Vista.

    Since you have lost the receipt of purchase of the computer, to get the date of purchase of the computer, you will have to contact the manufacturer of the computer and check the same.

    In Windows, you will not be able to find the date of purchase of the computer.

    However, you can find the date of installation of Windows on your computer that could help you.

    To find the date of installation of Windows on your computer, follow the steps below:

    1. Click on start and open computer.
    2. Click on the C drive and right click on the Windows folder.
    3. You can find the created Date of Windows folder.

    It will be useful.

    Thank you and best regards,

    Srinivas

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think

Maybe you are looking for