request to get the next date which is not a public holiday

Hello world

I need help for a query.  consider the following data

holiday

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

SELECT To_Date('12/28/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('08/31/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('05/25/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('05/04/2015','mm/dd/yyyy') double holiday

curr_DATE

-----------

SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/24/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/23/2015','mm/dd/yyyy') double holiday

data of curr_date are the main table.  given a date, I want to join the vacation and the date of the Curr so that the result will be a date that is not a holiday.  for example, what gives 28 Dec.  the next available in curr_date < 28 dec date is dec 25. However, dec25th is a holiday on the guest table if the output should be dec 24.

Another example is the following: given dec 25 date, the previous date, unless that Dec. 25 is dec 24th dec 24 is not in the host table output should therefore be dec 24.

Another example: I'll add another line to the curr_date table. If the data will look like this

curr_DATE

-----------

SELECT To_Date('12/28/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/24/2015','mm/dd/yyyy') double holiday

UNION ALL

SELECT To_Date('12/23/2015','mm/dd/yyyy') double holiday

given dec 29, the next available in curr_date date is less than 29 dec 28 dec. However, dec28th is holiday in the host table. the next available date is dec 25 in curr_date, but once again dec25 in the host table.  the next available date is 24, but this date is not in the host table output should therefore be 24/12/2015.

So basically I want to do this in the query by joining the two tables.  can anyone help? pl/sql is ok if it cannot be done using quries.

Hello

If you want to use a join, here's one way:

SELECT MAX (c.holiday) AS last_non_holiday

OF curr_date c

LEFT OUTER JOIN holiday h ON h.holiday = c.holiday

WHERE c.holiday< to_date="" (:cutoff_date,="">

AND h.holiday IS NULL

;

Tags: Database

Similar Questions

  • function/SQL to get the next weekend date of SUNDAY, in light of the current sysdate

    Hi all

    someone at - it a reliable piece of SQL or the function that takes the current SYSDATE as a parameter and returns the next date available weekend (SUNDAY)

    So for example if it is adopted as of today 01/07/2009 (Wednesday) it returns data 07/05/2009, which is the Date of Sunday following.

    Even if I went to Sunday 07/05/2009, it would go back the date 07/12/2009, which is this Sunday.

    Any help in advance apppreciated!

    Kind regards
    Satnam
    select next_day(sysdate, 'SUNDAY') from dual
    

    Good luck

  • Find the next available date which is not necessarily the maximum Date

    Morning people!

    I'm trying to find the next date of appointment (including any day after today) for a patient who may not be the maximum date for this person. I am doing this in Oracle Forms. My query works in SQL * more, but does not work in forms.
    FUNCTION get_next_sched_date(P_PATIENT_ID in varchar2) RETURN DATE IS
      v_next_scheduled_date   patient_visit.target_date%TYPE;
    
    BEGIN
      select next_target_date into v_next_scheduled_date
      from   ( select v.*, max(target_date) over (partition by patient_id) max_target_date,
                           lead(target_date) over (partition by patient_id order by target_date) next_target_date
               from   patient_visit v)
      where  patient_id = P_PATIENT_ID
      and    next_target_date >= SYSDATE
      and    max_target_date > next_target_date;
    
      return( v_next_scheduled_date );
    
    EXCEPTION
       when NO_DATA_FOUND then
         return(NULL);
    When I compile in Oracle Forms, it gives me an Error.Encountered symbol "(" quand attend une deles de valeurs suivantes:, de.) "

    I also noticed that Oracle Forms is not taste keywords such as LAG and LEAD. I'm working on Oracle Forms 9i.

    No idea what I'm doing wrong here? Thanks for listening to my harping on Monday. :-)
    Forms [32 Bit] Version 9.0.4.0.19 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    Published by: Roxyrollers on August 27, 2012 08:43

    Published by: Roxyrollers on August 27, 2012 08:46

    Hello

    The forms PL/SQL engine is never at the same level as the database one. It seams that you are using an older version of forms.

    François

  • How to get the old data 6 months from the current date?

    Hi friends,

    I have a table which includes historical data, which are having more than 1 years old data. The historical table gets updated once a week. My requirement is that I should get the latest data from the week of each month for 6 months according to the current data. I use oracle 10g.

    Can you please someone help in this.

    Thanks in advance

    SELECT last_day (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL))-7 start_dt.
    LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL)) end_dt
    OF THE DOUBLE
    CONNECT BY LEVEL<=>

    change as a result, I have provided you the start and end dates for your logic...

  • How to get the inline query which is drawn from the TAB specific Application.

    Hi all I use 10.2.0.4.0 oracle version.

    I want to capture the sql that is raised in my prod database when an applicaton tab is hit as it takes about 5 minutes for the tab to be loaded. So is it possible, for the inline sql, which is the origin of the problem, directly from the prod environment.

    (Note: I looked through the browser session in PROD DB for the query, but there, I found a lot of meetings and a lot of requests, I do not know how to distinguish the session being created by the specific tab I hit).

    >

    Hello

    I want to capture the sql that is triggered to my database of prod
    When an applicaton tab is hit as it takes about 5 minutes so that the tab
    to be loaded. So is it possible to get the inline sql, which is
    the origin of the problem, directly from the prod environment.

    Please, please tell us that you have a Test environment? Log into that, then run a trace.
    No doubt you can either descend all test for a few miinutes and/or
    easily distinguish sessions on your Test System? That's exactly what the test
    the environments are for.

    The SQL execution will be the same - you can go try to find
    the root cause of the problem.

    HTH,

    Paul...

  • Error "could not get the audio data in the file.

    Hello

    I get a lot of mistakes "Could not get the audio data in the file" when you open a project. Sometimes they will plant Premiere Pro CC 7.01 (Mac). But if no first works as usual, with the audio.

    I tried to convert the audio files (from the hearing) from 32 to 16 bit. It worked while opening a project once, but not the next time.

    Where can it be?

    Edit: I also get this error when importing audio: "error: Premiere Pro version 7.0 is not compatible with the first version of plugin Pro 5.7.4. Maybe it's related.

    I have it! This is the plugin Smartsound hurt. Got rid of him and no more errors.

  • Get the next row in the set of results under certain conditions

    Hello
    I have a result set with a column in ascending order of the numbers. Now, I want to compare these numbers to a value. If one of the numbers exactly matches the value then all is well and I use number < = value as a condition. If the value does not match exactly I want to get the next number in the result as well. A short example

    NB in resultset
    41
    82
    123
    164
    205
    246

    To compare with value = 200, I want to have

    41
    82
    123
    164
    205

    as a result.

    To compare with value = 164, I want to have

    41
    82
    123
    164

    Thanks for any advice.
    Carsten cordially

    You can use analytical functions for that. There are several options, here is one.

    with testdata as (select 41 num from dual union all
                      select 82  num from dual union all
                      select 123 num from dual union all
                      select 164 num from dual union all
                      select 205 num from dual union all
                      select 246 num from dual)
    /* end of test data creation */
        ,resulttab as (select num, nvl(lag(num) over (order by num) ,0) next_num
                       from testdata )
    select num
    from resulttab
    where next_num < 200 ;
    NUM
    ---
    41
    82
    123
    164
    205
    
    ...
    select num
    from resulttab
    where next_num < 164 ;
    41
    82
    123
    164
    
  • How can I get the filtered data from the first form

    How can I get the filtered data from the first form in a second form to make an update of the multi.
    Thank you very much

    William,

    I would use for this collections. A link is good if you need to pass a single value.

    1. create a collection
    2 fill the collection with your result set
    3. go in the page target and uses a method of a query in your link to this page
    4. your target page receives a request and allows you to edit documents.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • My MacBook Pro was built in mid-2009, I understand that I won't be able to get the next Sierra of OS.  I just put a new hard drive 700 GB, more I added a new battery to include a new CD/DVD drive.  I spent more than 400 million dollars. What I need to by

    My MacBook Pro was built in mid-2009, a 2.6 GHz, 13-inch, I just put a new hard drive 700 GB and I added a new battery to include a new CD/DVD drive.  I spent more than 400 million dollars.

    I understand that I won't be able to get the next Sierra of OS. I need to by a new Mac?

    Talk to the people the more I would get if I turn in I'd get is about are about $ 100 million.  Please tell me it isn't so.

    If you want Siera you will need a new Mac, but you can continue to use the old one as long as you want.

  • New problem, Lycos Mail is my home page. When I open a new window I usually get the Google search, which is what I want. Now, somehow when I open a new window I Yahoo search. How can I change to Google? Thank you, Randy

    New problem, Lycos Mail is my home page. When I open a new window I usually get the Google search, which is what I want. Now, somehow when I open a new window I Yahoo search. How can I change to Google?
    Thank you
    Randy

    A new window opens by default with the homepage.

    See:

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Get the latest data of Variable shared before disconnecting from the network

    Hello.

    I use Shared - published network variables for my communication between two PC's. Each LV software will pass the data to another.

    Sometimes the wireless connection to become really bad and the network connection stops.

    I want to get the latest data. Currently my VI will show the value '0' on the variable shared data once the connection is cut.

    I tried using shift, but she registers the same results.

    Can someone show me how I can stay past data when the network connection is disconnected.

    Thank you very much.

    Kind regards

    Hello Fan, Ravens

    It works! Thank you very much.

    Kind regards

  • Get the raw data to map its (SDK)

    I did a search on sound cards and many forums have been useful.  I have just a few quick questions.

    I have a card his (CardDeluxe http://www.digitalaudio.com/) connected to the computer through a PCI.  My goal is to get the raw data from the card and plug and it blow in analytics in CVI.  I don't know how to "talk" to my sound card.

    Of course, my main question is above, but to the refine some concerns...

    I guess I need the SDK libraries for that.  For this, I just need to install the MSN help libraries?

    Is this possible in the Basic Version, or if the full Package of CVI is necessary?

    I have not done things well at low altitude, but it looks like getting a wav file is necessary.  I can't use anything outside of the applications I want to eventually create a program automatically record and play at a time (sync) précis.

    Thanks in advance.

    This site is what I was looking for.  The zip file contains an exe as file c source code.

    http://paulhoule.com/phsrec/index.php

    Edit:

    There is also some info here - http://forums.ni.com/t5/LabWindows-CVI/wav/m-p/235344

  • problem to get the current date in qml

    Hello world

    I'm trying to get the current date in c ++ and qml and I used the class QDate, but it still has some problems:

    Code:

    =====================================================

    QDate * nowdate = new QDate;
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (nowdate-> currentDate()));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    ===========================================================

    After setting the nowdateMap, I'm able to get the date in the application, but the format is really weird, I did not use QDatetime, but the restult of shows like ' 2013-1 - 3 T 00: 00:00 ", how can I get rid of the final"T00:00:00 "? or is there a better way to get the current date?

    Thank you

    QDate nowdate is QDate::currentDate();.

    QString nowdatestring = nowdate.toString (); / / to get the date string format, you can define the shape of toString(), you can //search it
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (QString (nowdatestring)));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    then in the file qml, using nowdateMap.date will do.

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • How to add two lines when the second row is not visible, but also gets the first data line too?

    Mr President

    Jdev worm is 12.2.1

    How to add two lines when the second row is not visible, but also gets the first data line too?

    I want to add two lines like below picture, but want the second to remain invisible.

    tworows.png

    I asked this question but my way of asking was wrong, that's why for me once again.

    Concerning

    Try to follow these steps:

    1. in the database table to add the new column "JOIN_COLUMN" and add the new sequence "JOIN_SEQ".

    2. Add this new column in the entity object. (You can add this in entity object by right clicking on the entity object and then select "Synchronize with database" then the new column and press on sync)

    3. in your bookmark create button to create only one line NOT 2 rows.

    4 - Open the object entity--> java--> java class--> on the entity object class generate and Tick tick on the accessors and methods of data manipulation

    5 - Open the generated class to EntityImpl and go to the doDML method and write this code

      protected void doDML(int operation, TransactionEvent e)
      {
        if(operation == DML_INSERT)
        {
          SequenceImpl seq = new SequenceImpl("JOIN_SEQ", getDBTransaction());
          oracle.jbo.domain.Number seqValue = seq.getSequenceNumber();
          setJoinColumn(seqValue);
          insertSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        if(operation == DML_UPDATE)
        {
          updateSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn());
        }
    
        super.doDML(operation, e);
      }
    
      private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "Insert into table_name (COLUMN_1,COLUMN_2,COLUMN_3,JOIN_COLUMN, HIDDEN_COLUMN) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + joinColumn + "', 1)";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn)
      {
        PreparedStatement stat = null;
        try
        {
          String sql = "update table_name set column_1='" + value1 + "', column_2='" + value2 + "', column_3='" + value3 + "' where JOIN_COLUMN='" + joinColumn + "'";
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    

Maybe you are looking for

  • My firefox has no command line

    My firefox has no command line, or any other web site for important. In the Web Developer menu, the only tool I have is the page source. I re-installed firefox several times and set up different channels, but still no dice.

  • Satellite 1800-400 does not start, or crashes after upgrading RAM

    I have the original configuration of RAM for the S1800-400 with 120 MB. I bought a 256 MB RAM with the following description: EXT256-3069/JR, MEM 256 MB RA Toshiba Satellite PRO 4600 series C650, PIII-7500/750/800 #PA3069U (I think the brand is Trans

  • Qosmio G50-12 q: no audio signal while moving the video files from the camcorder

    Hello I have a portable PC Toshiba Qosmio G50 - 12 q with 640 GB HARD drive, and equipped with 4 GB of Ram saw the Completed window system upgraded to the version of service pack 2 I connected the video camera Sony PC 115 to the PC via the I.Link IEE

  • Windows 8 Pro will not activate after recovery

    Hi all A few days ago, the drive hard my Lenovo ThinkCentre E73 suddenly stopped working. After the replacement of what I did full software recovery with Windows 8 Professional CD I ordered a Lenovo time ago. But after the Windows installation is not

  • LaserJet_600_M602_NW_access

    Hello I have LaserJet 600 M602. How to install auth 802.1 x? When I get the name, password, server address and then I click on submit, nothing happens. I can see x auth 'successful' but 802.1 is still inactive. I also network access protection server