Take the date of the largest of the 3 Date columns

Hi all

I have 3 Date/time columns in my table:

DateTime_1,
DateTime_2,
DateTime_3

Now select the date maximum or greater of any of these 3 columns. A column can be null. I tried to use a combination of coalesce and features larger to get the maximum date value. When I use a coalesce on 3 columns, it works fine, but when I nested him coalesce in the greater function, that is to say Greatest (Coalesce (...)) it takes a null value. Should I include an nvl on each column?

Any help would be appreciated.

Thank you
Ed

spalato76 wrote:

all 3 columns can be null, in which case, I would like to keep the value zero, then this might be difficult...

Not difficult at all, unless 4712-01-01 BC is valid a date for you (which is very likely):

NULLIF(
       GREATEST(
                NVL(DateTime_1,DATE '-4712-01-01'),
                NVL(DateTime_2,DATE '-4712-01-01'),
                NVL(DateTime_3,DATE '-4712-01-01')
               ),
       DATE '-4712-01-01'
      )

SY.

Tags: Database

Similar Questions

  • Take the minimum value for table data

    I'm storing test data in a table, with the hope that I can output the minimum value of the data. So far, I have used the table of max/min but can't make it work how I want. The test runs continuously in a loop of the holder. I get the minimum values in the table, but I would like to change the number of samples that the table contains, before it generates a minimum. The other option is that I run the test for a period of time (e.g. 3 seconds) and the table stores the data for this time then output 1 minimum value for the entire period.

    My current configuration VI is attached.

    Very appreciated

    Chris

    The size of the array in your VI is determined by the number of samples that you collect in your DAQ assistant, who is now 100 samples.  Never more, never less.

    How many samples do you want before you determine the minimum?

    Maybe what you really want to do is to build the table in the while loop and store it in a shift register, and when the loop has repeated enough times, then you take the minimum of built table.

  • Take the real component of the logarithms of negative numbers

    I'm taking the log of a number, and I need the real component. For example: log(-5) = 0.698970004 + 1.36437635 i

    I have to be able to take the 0.698970004 and use it, while just Labview says his NAN.

    I just figured as a CPD, I can throw the entries, but then I still don't know how to convert with only the real component.

    Ideas?

    Thank you

    The trick is to define the representation of the data type of the lap number in the primitive logarithm. After that, it is easy to divide the complex number in real and imaginary components:

  • How take the sum of middle iteration last iteration?

    Hello! PLS, can anyone help, I have six variables and you want to take the sum of each of the variables separately from the middle of the iteration to the last iteration (i.e. iteration 6 iteration 12). Attached are the vi file and data entry.

    I won't mess with your design of control thingy... but here is the simple and direct way to the sum of the average in last interation.  I use random numbers here, but you can enter your own values once you get out your straigthend formula.

    Basically, it works like this: feed values into a tunnel of indexation.  Which will make each set of values in an array whose length N where N is the number of iterations.

    Find the array size and divide by 2.  Remember that arrays start at index zero, so 12 iterations will give you 0,1,2,3,4,5,6,7,8,9,10,11.

    You want the second half, so it's 6,7,8,9,10 and 11.  Subset of the table to select 6 elements, starting with element 6... Then take the sum of table.

  • 6901 phones fails to take the ip address

    Hello

    I am configuring 6901 phone with call 8.6 Manager.

    The problem is that these phones do not take the ip address and through the datasheet, I found that these phones do not support of VLAN.

    In our configuration, we use the 2960 switches and there are several VLANs and VLAN voice and data is separated so I removed the vlan data port swithc and just kept the vlan voice and still should not be any ip address.

    When I do come to the port of data switch vlan it take the ip address of the vlan database but I want to get the ip address of the vlan voice.

    If someone is facing this problem before please share.

    Hi Malik.

    I think you can see this bug;

    CSCth34329 - 69xx accepts DHCP Offer tagless after sending Discover on Vlan VoIP

    Description

    Symptom:
    69XX phone receives an IP address on one local VIRTUAL network other than the VLAN voice.
    Conditions:
    This will happen if there are two different DHCP servers for the VLAN voice and data, and the data from the server DHCP VLAN are not aware of VLAN.
    Workaround solution:
    Delete the configuration of VLAN voice on the switchport to server DHCP VLAN data.
    Additional information:
    Same problem exists on other phone models. For an example, see CSCsa85042 .

  • When I perform "All delete and reinstall Windows" Windows 8, it will take the product key of Windows 8?

    I have a TOSHIBA SATELLITE P850 with 8 windows pre installed. There is no Windows 8 key at the back of the laptop. Thus,.

    (1) I like to use 'remove all and reinstall windows' own 8. It will take the Windows product key? If so how do I get my windows key?

    (2) I want to put up-to-date then Windows 8.1. After the windows 8.1 update, my recovery partition will be windows 8? or 8.1? If windows 8, how will replace the recovery with Windows 8.1 partition?

    The key is embedded in the bios. It is not necessary for reassembly. Your recovery partition will always win 8 after update to 8.1. You are unable to update, but you could reinstall 8.1 if you ever have to return to the factory settings. Do a recovery drive of the new facility on a flash drive. See all recovery options available in Windows Help.

  • JavaScript input parameter should take the value of the element page Apex

    I have a JavaScript function which i dwonloaded ffrom net to generate bar codes

    DrawCode39Barcode(data,checkDigit).

    I call this function in the body of page attribute by using the following script

    < div id = "P5_X" > < / div >

    < script type = "text/javascript" >

    / * < ! [CDATA [* /]]

    function get_object (id) {}

    var object = null;

    If (document.layers) {}

    object = document.layers [id];

    } Else if (document.all) {}

    object = document.all [id];

    } else if (document.getElementById) {}

    object = document.getElementById (id);

    }

    Returns the object;

    }

    get_object('P5_X').innerHTML = DrawCode39Barcode('1-1-1111',0);

    < /script >

    When I run the page, the barcode for the value 1-1-1111' is generated. Please help so that when this page is running it will automatically take the value of the page item P5_X as parameter instead of hard coded value ' 1 - 1-1111'

    I think it would be simpler. You use the same id for the region and the order of the day, they must be different id

    JavaScript code can be in a dynamic action who sets fire to the loading of the page, or load Execute on the page of your page properties section.

    $('#barcode').html (DrawCode39Barcode ($v ('P5_X'), 0));

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • Take the difference of two tables

    Hello

    I have two tables where in I need to take the difference between the two columns of different tables and show as decimal below:

    Table A

    Name, salary

    x 10.5

    y - 10.32

    z 5

    Table B

    Name, salary

    x 10.5

    y - 10.32

    z 3

    a 12

    Output:

    Name_A, Name_B, salary, remarks

    x, x, 0, no diff

    y, y, 0, no diff

    z, z, 2 Diff is here

    , one, no data, no data from the previous

    Hello

    Try ythis:

    with table_a as
    (
    SELECT 'X' NAME, SALARY, 10.5 DUAL UNION ALL
    SELECT THE NAME OF 'Y',-10.32 SALARY OF DOUBLE UNION ALL
    SELECT THE NAME OF 'Z', 5 DOUBLE SALARY
    )
    table_B as
    (
    SELECT 'X' NAME, SALARY, 10.5 DUAL UNION ALL
    SELECT THE NAME OF 'Y',-10.32 SALARY OF DOUBLE UNION ALL
    SELECT THE NAME OF 'Z', 3 DOUBLE UNION ALL SALARIES
    SELECT 'A' NAME, SALARY 12 DUAL FROM
    )
    SELECT
    COALESCE(A.NAME,B.NAME) NAME
    , NVL (TO_CHAR (A.SALARY - B.SALARY), 'NO DATA') SALARY
    , CASE WHEN A.SALARY - B.SALARY = 0 THEN 'NO DIFFERENCE '.
    WHEN B.SID IS NULL, "NO DATA OF THE PREVIOUS.
    WHERE B.NAME IS NULL, "NO DATA FROM NEXT.
    ANOTHER 'DIFFERENCE IS THERE.
    END NOTE

    Of
    TABLE_A HAS
    TABLE_B FULL OUTER JOIN B ON (B.SID = B.NAME)
    ;

    NAME SALARY NOTE
    ---- ---------------------------------------- ---------------------
    X 0 NO DIFFERENCE
    Y 0 NO DIFFERENCE
    Z 2 THE DIFFERENCE IS THERE
    A NUMBER OF DATA NO DATA FROM THE PREVIOUS

    Kind regards

    Peter

  • While you take the cumulative incremental backup RMAN. Meanwhile users ke

    While you take the cumulative incremental backup RMAN.
    During this time users keep be updated, insert the corresponding schema.
    But my Client doesn't backup up-to-date. Is it possible to get the up-to-date backup?
    (If I have something wrong, sorry about that, that was my interview question)

    Thanks for all,
    Kind regards
    DB

    DB wrote:
    While you take the cumulative incremental backup RMAN.
    During this time users keep be updated, insert the corresponding schema.
    But my Client doesn't backup up-to-date. Is it possible to get the up-to-date backup?
    (If I have something wrong, sorry about that, that was my interview question)

    Thanks for all,
    Kind regards
    DB

    RMAN backup is not compatible and easy to follow on-line transactions. If it's something any purpose of migration suggest taking COLD backup.
    If it's no way suggested, then after your entire + cumulative backups, however, that data will be available in archives

  • Insert data according to the length of column in table

    Hello

    If the length of the characters is more than one defined causes error. It's very embarrassing especially when get data dynamically

    and our query does not insert information that we expect.

    While trying to find the solution an idea came to my mind that, before insertion, so we check that the next data is greater than the specified length

    Take only the amount of characters that can be inserted and ignore the rest.

    I thought that the query as follows but failed.
    SQL> insert into cvDetails(cv_id,objectives) values(9687,substr("Hello",1,3950));
    insert into cvDetails(cv_id,objectives) values(9687,substr("Hello",1,3950))
                                                               *
    ERROR at line 1:
    ORA-00984: column not allowed here
    Is it possible to insert data up to the amount this column length defined by ignoring the obsolete characters and if the data

    length is less defined length of column, and then insert it as it is?

    Thank you in anticipation

    Hello

    Do not use double quotes as the string delimiters:

    SQL> create table test_nsa (str varchar2(10));
    
    Table created.
    
    Elapsed: 00:00:00.88
    SQL> insert into test_nsa values (substr('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',1,10));
    
    1 row created.
    
    Elapsed: 00:00:00.08
    
  • Question about the use of SQLLDR to load a date column in a new format.

    Hello.

    I'm having a problem using SQLLDR which is really starting to annoy me. We are running Oracle 10.2.0.4 and I am trying to load the data into a flat file generated by Excel in using SQLLDR table. The problem I have is that the date in the flat file column is in the format: DD/MM/YYYY and the user wants the data to be in format: YYYYMM

    Here's a copy of my control file:

    DOWNLOAD THE DATA
    INFILE 'c:\temp\DESKTOP_DATA.txt '.
    ADD
    IN THE OPCTI TABLE. PERF_LEVEL
    FIELDS TERMINATED BY "" "
    trailing nullcols
    (CUSIP,
    DATE_AS_OF ' TO_DATE (: DATE_AS_OF, 'YYYYMM'). "
    ONE_MO_DELINQ_30_59,
    ONE_MO_DELINQ_60_PLUS,
    ONE_MO_BANKRUPT_RATE,
    ONE_MO_FORECLOSURE_RATE,
    ONE_MO_REO_RATE,
    ONE_MO_DELINQ_60_89,
    ONE_MO_PRIN_RECOVERY,
    ONE_MO_PRIN_LIQ,
    ONE_MO_COLLAT_BAL,
    CURRENT_CREDIT_SUPPORT,
    ONE_MO_CDR
    )

    And when I call SQLLDR, I get the following message:

    Sheet 1: Rejected - error on the OPTCI table. PERF_LEVEL, the DATE_AS_OF column.
    ORA-01858: a non-digit character was found here where was waiting for a digital

    Any idea on what I'm missing? When I started, it seemed to be quite simple.

    Thank you!

    so you want to take the character input, convert it to a date and then convert back to a different character format.

    Select to_char (to_date (12 November 09 ',' MM/DD/YY '), "YYYYMM") twice;

    200911

    Try something like that.

  • Group by and take the year Record Max

    Hello

    I have the data as below:

    A     B     C     D     E
    --- --- ---- ---- -----
    1. A VAC 2008 AAA
    1. A BBB CCC 2007
    1. A CCC CCC 2009
    2 B ATT TTT 2004
    2 B BYY YYY 2009
    2B CZZ ZZZ 2006

    Here I must eliminate duplicates using A, B and take the record with max (E)

    If the output should be:

    A     B     C     D     E
    --- --- ---- ---- -----
    1. A CCC CCC 2009
    2 B BYY YYY 2009


    Please help me how I can do this.
    Thanks in advance

    Mahesh
    SQL> with t as (
     select 1 a, 'A' b, 'ACC' c, 'AAA' d, '2008' e from dual union all
     select 1, 'A', 'BCC', 'BBB', '2007' from dual union all
     select 1, 'A', 'CCC', 'CCC', '2009' from dual union all
     select 2, 'B', 'ATT', 'TTT', '2004' from dual union all
     select 2, 'B', 'BYY', 'YYY', '2009' from dual union all
     select 2, 'B', 'CZZ', 'ZZZ', '2006 ' from dual
    )
    --
    --
    select max(a) keep (dense_rank last order by e) a,
           max(b) keep (dense_rank last order by e) b,
           max(c) keep (dense_rank last order by e) c,
           max(d) keep (dense_rank last order by e) d,
           max(e) keep (dense_rank last order by e) e
      from t
    group by a
    /
             A B C   D   E
    ---------- - --- --- -----
             1 A CCC CCC 2009
             2 B BYY YYY 2009 
    
    2 rows selected.
    
  • Custom error Page how AAU take the return URL

    Hi all

    I create a custom error page and I was wondering is there a way to take
    the URL to which the error.

    Example:

    While watching http://my_site.com/sectionA/
    you follow the link to http://my_site.com/sectionB/
    Unfortunately http://my_site.com/sectionB/ does not exist
    and you are redirected to my page http://my_site.com/errorPage/ error

    Is it possible when I'm on http://my_site.com/errorPage/ to know that
    It was who raises the error http://my_site.com/sectionB/

    Thanks in advance,
    Fr. Ilian Iliev

    Is - this site studio?

    Go to the url that was bad, redirected to your section of custom errors, and then in the url, add? IsJava = 1, and then press ENTER. This returns the data that is located behind the page.

    One of the variables I see is called originalSiteRelativeUrl and it seems to contain information you're looking for.

    Give that a try and let us know!

  • I bought the iphone 6 to find her icloud is locked. I tried to contact the owner, but I can't reach him. are there opportunities to take the step of activation? Thank you.

    I bought the iphone 6 to find her icloud is locked. I tried to contact the owner, but I can't reach him. are there opportunities to take the step of activation? Thank you.

    Hello

    You describe Activation Lock, which prevents the unauthorized use of the iPhone if it is lost or stolen.

    This can be disabled either by:

    • The former owner, grabbing their Apple ID and password of the device.
    • The previous owner, removing the iPhone in their list of devices to locate my iPhone via iCloud.com.

    In both cases, be sure to follow the instructions in the first article below.

    If you can not organize or either of these actions, then you will not be able to use the iPhone. There is no way around this security feature.

    More information and instructions:

    Turn off find my iPhone Activation Lock - Apple Support

    Find my iPhone Activation Lock - Apple Support

  • As a person in the main video takes the floor, I want to insert an image, while the audio stays...

    I have one main video where a woman takes the floor. In his speech, I would like to continue talking while using different images that makes her disappear, but not the audio... How do I with IMovie on my IPhone?

    See iMovie for iOS (iPhone, iPod touch): organize audio clips. You should be able to detach the original clip audio but keep them lined up, allowing you to adjust the video and then move on to still images while the audio continues to play.

    TT2

Maybe you are looking for