Choose the nearest Date of a group of Dates

Hey people!
I need to find the closest Date that corresponds to a given Date. The earliest Date of the Group may be lower or higher than the Date that I will try to find.

I have two columns: VISIT_DATE and ACTUAL_DATE. The VISIT_DATE columns a number of records with different dates, while ACTUAL_DATE column would have only one record per student.

Here is an example of dates:
Visit Date      Actual Date
==========================
01-APR-09     19-MAR-10
16-NOV-09     19-MAR-10
17-MAR-10     19-MAR-10
21-MAR-10     19-MAR-10
04-APR-11     19-MAR-10
15-JUN-11     19-MAR-10
19-SEP-11     19-MAR-10
24-FEB-12     19-MAR-10
The nearest date you for March 19, 10 are in fact 17 March 10 and March 21, 10. In this case, I would need to pick up the two records. Any help would be greatly appreciated. :-)

Thank you!
SQL> select visit, actual
  2  from
  3  (
  4     select visit, actual
  5           ,dense_rank() over (order by abs(visit - actual)) dr
  6     from   t
  7  )
  8  where dr = 1
  9  ;

VISIT                ACTUAL
-------------------- --------------------
17-MAR-2010 00:00:00 19-MAR-2010 00:00:00
21-MAR-2010 00:00:00 19-MAR-2010 00:00:00

Tags: Database

Similar Questions

  • Join the nearest date "not used".

    I need to join the following tables by the next date "not previously signed" the nearest:

    start_table:

    st_id start_dt
    start031-dec-2014
    Start1

    January 3, 2015

    Start2January 5, 2015
    start3January 7, 2015
    Debut48 January 2015
    Debut5January 14, 2015

    end_table:

    end_id end_dt
    end0January 1, 2015
    End1January 2, 2015
    End2January 13, 2015
    End3January 15, 2015
    bout4January 17, 2015
    end519 January 2015
    end6January 20, 2015

    Result:

    st_id end_id
    start0end0
    Start1End2
    Start2End3
    start3bout4
    Debut4end5
    Debut5end6

    start0 joined end0, because the closer to the date of the next 31-dec-2014 is 1 January 2015

    Start1 joined end2, because the closer to the date of the next January 3, 2015 is January 13, 2015.

    Start2 joined end3, because as well as the date of the next more close January 5, 2015 is 13 January 2015, this is already accompanied Start1, so she joined next January 15, 2015.

    start3 joined bout4, because the date of the next although most close January 7, 2015 is 13 January 2015, this one is already joined by Start1, earliest date is January 15, 2015, but is also already joined by start2, then he joined the next available date January 17, 2015.

    Database: 11g

    Thanks in advance

    [UPDATE: changed line 37 to add "or cnt > = 0".] [This covers cases where there are more departures that ends at first.]

    Jiri.Machotka - Oracle wrote:

    I found a non recursive algorithm for this problem...

    I came up with something similar: no recursion, no joins, each table read only once.

    1. UNION ALL marked times 1 tables, with lines of departure and end marked lines - 1
    2. Order by date (first lines) and get a combination of 1's and - 1's.
      so when there are too many lines to end, the sum is negative.
    3. Get the previous cumulative minimum! Then take that end with a sum running lines, at less than the previous minimum.
    4. The remaining lines will have an end of line for each line of departure. Now number lines starting from 1 to N and the lines at the end of 1 to N, then match lines start and end in pairs. I use PIVOT to do this.
    WITH end_table (end_id, end_dt) AS (
      select 'end0',to_date('01-jan-2015','dd-mon-yyyy') from dual union all
      select 'end1',to_date('02-jan-2015','dd-mon-yyyy') from dual union all
      select 'end2',to_date('13-jan-2015','dd-mon-yyyy') from dual union all
      SELECT 'end3',to_date('15-jan-2015','dd-mon-yyyy') FROM dual UNION ALL
      select 'end4',to_date('17-jan-2015','dd-mon-yyyy') from dual union all
      SELECT 'end5',to_date('19-jan-2015','dd-mon-yyyy') FROM dual UNION ALL
      SELECT 'end6',to_date('20-jan-2015','dd-mon-yyyy') FROM dual
    )
    ,start_table (start_id, start_dt) AS (
      select 'start0',to_date('31-dec-2014','dd-mon-yyyy') from dual union all
      select 'start1',to_date('03-jan-2015','dd-mon-yyyy') from dual union all
      select 'start2',to_date('05-jan-2015','dd-mon-yyyy') from dual union all
      select 'start3',to_date('07-jan-2015','dd-mon-yyyy') from dual union all
      select 'start4',to_date('08-jan-2015','dd-mon-yyyy') from dual union all
      SELECT 'start5',to_date('14-jan-2015','dd-mon-yyyy') FROM dual
    )
    , start_and_end as (
      select -1 rowtype, end_id id, end_dt dt from end_table
      union all
      select 1, s.* from start_table s
    )
    , running_count as (
      select se.*,
        sum(rowtype) over(order by dt, rowtype desc) cnt
      from start_and_end se
    )
    , filtered_ends as (
      select rowtype, id, dt from (
        select rc.*,
          min(decode(rowtype,-1,cnt)) over(
            order by dt, rowtype desc
            rows between unbounded preceding and 1 preceding
          ) mincnt
        from running_count rc
      )
      where cnt >= nvl(mincnt,0) or cnt >= 0
    )
    select * from (
      select rowtype, id,
      row_number() over(partition by rowtype order by dt) rn
      from filtered_ends
    )
    pivot(max(id) for rowtype in(1 st_id, -1 end_id))
    order by rn;
    

    ST_ID END_ID RN

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

    1 start0 end0

    2 Start1 end2

    3 Start2 end3

    4 start3 bout4

    5 debut4 end5

    Debut5 6 end6

  • find the nearest date of...

    I have four dates with a different price for each date:

    15/02/12 $150
    02/12/12 $100
    02/10/12 $50
    02/08/12 $25

    I want to choose a date that > = 10/02/12(my date)
    generally, the query will return two date 02/12/12 and 15/02/12
    but I want to return only a single date 02/12/12, which is very close and is superior to mydate(10/02/12)...

    Thanks in advance...

    Try this

    SELECT PFR_FEE_RATE
    FROM PAYMENT_FEE_RATE
    WHERE  PFR_DATE=(SELECT     MAX(PFR_DATE)
                      FROM     PAYMENT_FEE_RATE
                      WHERE          PFR_DATE     <=TO_DATE ( '10/02/2012', 'DD/MM/YYYY'  ))
    

    Hope this will help you

  • Choose the freespace data store

    Hi all

    I create VMS of the model, workflow

    I want to create list with 5 datasores with more space free to choose,

    no idea how to do?

    Depends on how you sort... If your sort option is one that has the most space that the first element of the array, you simply have a scriptable task that which takes the output array of actions as input, and then in the script task, get the first element (ds var myArray = [0]) and then go "ds" on the rest of your workflow.

  • How to choose the following data using sql?

    Hi people,

    I use oracle 10g.i have two tables as follows.

    PROGRAMMER
    PNAME                          DOB       DOJ       SEX   PROF1                          PROF2                             SALARY
    ------------------------------ --------- --------- ----- ------------------------------ ------------
    ALIAF                          02-JUL-64 02-JUL-90 M     CLIPPER                        COBOL                               2800
    JULIANA                        31-JAN-68 31-JAN-60 F     COBOL                          DBASE                               3000
    KAMALA                         30-OCT-68 30-OCT-92 F     C                              DBASE                               2900
    MARY                           24-JUN-78 24-JUN-91 F     C++                            ORACLE                              4500
    NELSON                         11-SEP-65 11-SEP-89 M     COBOL                          DBASE                               2500
    PARTICK                        10-NOV-65 10-NOV-90 M     PASCAL                         CLIPPER                             2800
    QADIR                          31-AUG-65 31-AUG-91 M     ASSEMBLY                       C                                   3000
    RAMESH                         03-MAR-67 03-MAR-91 M     PASCAL                         DBASE                               3200
    REBECCA                        01-JAN-67 01-JAN-90 F     BASIC                          COBOL                               2500
    REMITHA                        02-DEC-69 02-DEC-92 F     PASCAL                         BASIC                               3600
    REVATHI                        02-DEC-69 02-DEC-92 F     PASCAL                         BASIC                               3700
    VIJAYA                         14-DEC-65 14-DEC-92 F     FOXPRO                         C                                   3500
    ANAND                          21-APR-66 21-APR-92 M     PASCAL                         BASIC                               3200
    SOFTWARE
    PNAME                          TITLE                          DEV_IN                   DCOST     SCOST      SOLD
    ------------------------------ ------------------------------ -------------------- --------- -------
    ANAND                          PHARACHUTES                    BASIC                     6000       400        43
    ANAND                          VIDEO TITLLING PACK            PASCAL                   16000      7500         9
    JULIANA                        INVENTORY CONTROL              COBOL                     3500      3000         0
    KAMALA                         PAYROLL PACKAGE                DBASE                    20000      9000         7
    MARY                           FINANCIAL ACCOUNT              ORACLE                   85000     18000         4
    MARY                           CODE GENERATOR                 C                        20000      4500        23
    PARTICK                        READ ME                        C++                        900      2000        84
    QADIR                          BOMBAS AWAY                    ASSEMBLY                  5000       750        11
    QADIR                          VACCINES                       C                         3400      1900        21
    RAMESH                         HOTEL MANAGEMENT               DBASE                    35000     12000         4
    RAMESH                         DEAD LEE                       PASCAL                    4500       600        73
    REMITHA                        PC UTILITIES                   C                         5000       725        51
    REMITHA                        TRS HELP PACKAGE               ASSEMBLY                  6000      2500         6
    REVATHI                        HOSPITAL MANAGEMENT            PASCAL                   75000      1100         2
    REVATHI                        QUIZ MASTER                    BASIC                     2100      3200        15
    Now the task is to display the details of the software that has been developed in the language which is neither the first nor the second jurisdiction of the programmer.can u pls help me solve it.thanks in advance.


    Reg
    vids

    Now the task is I have to display the details of the software that has been developed in the language which is neither the first nor the second skill of the programmer

    SELECT s.*
    FROM   software s,
           programmer p
    WHERE  s.pname = p.pname
           AND s.dev_in NOT IN ( p.prof1, p.prof2 );  
    
  • Identify the Start Date, based on other summary values.

    I am runing:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production

    CORE11.2.0.1.0 Production

    AMT for Linux: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    Here are the general dateset that I try.

    with dateset as)
    Select 1 worker, 8 totalhours, 27 April 15 ' work date, 1 installation, 35 production of all the double union
    Select 1, 8, April 26, 15 ', 1, 35 of all the double union
    Select 1, 0, 25 April 15 ', 1, 0 of all the double union
    Select 1, 0, 24 April 15 ', 1, 0 of all the double union
    Select 1, 6, 23 April 15 ', 1, 20 of all the double union
    Select 1, 7, April 22, 15 ', 1, 27 union double all the
    Select 2, 4, April 24, 15 ', 1, 15 union double all the
    Select 2, 4, April 27, 15 ', 1, 15 union double all the
    Select 2, 4, April 22, 15 ', 1, 15 union double all the
    Select 3, 6, 26 April 15 ', 2, 32 union double all the
    Select 3, 6, April 25, 15 ', 2, 32 union double all the
    Select 3, 6, 24 April 15 ', 2, 32 union double all the
    Select 3, 6, 22 April 15 ', 2, 32 union double all the
    Select 3, 6, 23 April 15 ', 2, 32 double
    )

    Select
    *
    of dateset

    I'm trying to get a date range or have the identified dates for the first harvest of the end date and then have hours max per each day added up to at least 15 hours and find the total production to examine these days that are.

    So, if I choose the end date of April 25, 15 ', then I identified the maximum working hours at the facility. So because no work was allocated to the 25 for installation 1, 24 is the actual start date, in a plant worker 2 3 had 6 hours work, if installation date of end is the 25 hours max of 6. Noticed that the installation has 24, 23 and 22 total hours bing 17 (always meets the requirements of 15 hours), while the installation of 2 has 18 hours 25, 24, 23 (requirement for hours 15 min)

    This is the prison of result data group.

    with datasettwo like)
    Select 4 maxhours, 24 April 15 ' work date, 1 installation, 15 totalproduction of all the double union
    Select 6, April 23, 15 ', 1, 20 of all the double union
    Select 7, April 22, 15 ', 1, 27 union double all the
    Select 6, April 25, 15 ', 2, 32 union double all the
    Select 6, April 24, 15 ', 2, 32 union double all the
    Select 6, April 23, 15 ', 2, 32 double
    )

    Select
    *
    of datasettwo
    order by
    installation
    date desc

    so, how would I go about konwing when start work Date date has been reached because the total number of hours has been reached or excited the limit.

    All thoughts.

    With the help of everyone, thank you,

    It's the rough solution I was looking for, could probably be cleaner.

    I apologize for the confusion.

    so, for April 27, the total production for that day for installation 1 is 50 units and 8 hours max.

    and if the end date is sent to the 24

    April 22 is the total output of 32 units and hours max of 6 for this day.

    with dateset as)
    Select 1 worker, 8 totalhours, 27 April 15 ' work date, 1 installation, 35 production of all the double union
    Select 1, 8, April 26, 15 ', 1, 35 of all the double union
    Select 1, 0, 25 April 15 ', 1, 0 of all the double union
    Select 1, 0, 24 April 15 ', 1, 0 of all the double union
    Select 1, 6, 23 April 15 ', 1, 20 of all the double union
    Select 1, 7, April 22, 15 ', 1, 27 union double all the
    Select 2, 4, April 24, 15 ', 1, 15 union double all the
    Select 2, 4, April 27, 15 ', 1, 15 union double all the
    Select 2, 4, April 22, 15 ', 1, 15 union double all the
    Select 3, 6, 26 April 15 ', 2, 32 union double all the
    Select 3, 6, April 25, 15 ', 2, 32 union double all the
    Select 3, 6, 24 April 15 ', 2, 32 union double all the
    Select 3, 6, 22 April 15 ', 2, 32 union double all the
    Select 3, 6, April 27, 15 ', 2, 32 double
    )

    Select
    installation
    date of work
    totalproductionperday
    maxhoursperday
    sum (maxhoursperday) on totalhours (installation partition)

    from (select distinct)
    installation
    date of work
    maxhoursperday
    totalproductionperday
    , case when sum (maxhoursperday) over (partition by order of ease by date desc)
    -sum (maxhoursperday) over (partition by establishment, work date)<>
    then 'Y '.
    another "n".
    end to_include
           
    (select
    installation
    date of work
    max (totalhours) maxhoursperday
    sum (production) totalproductionperday
                   
    of dateset
                     
    where date of work<= to_date(:enddate,="" 'dd-mon-rr')="" --="" end="" date="">
                   
    Group
    installation
    date of work
    )
    )

    where to_include like 'Y '.

    order by
    installation
    date desc

  • DateField, can not be able to select the current date

    Hai,

    I use DateField in my application. Initially, the date field is showing-/-/---(JJ/MM/AAAA) this format. So if I click on this field to date I can't able to select the current date. If I go on any later date or past date and define it and that I can not choose the current date.

    Hai,
    Thax for your quick response...
    I found this question in "Issue Tracker" here: https://www.blackberry.com/jira/browse/JAVAAPI-1163

  • Choose the date between December 1 and March 1

    I have a table in which I include the date column and the temperature.

    Now, I want to choose the average temperature per season per year. For the spring until autumn, it's perfectly feasible:

    But what about winter. Winter begins December 1st and ends March 1 of next year. Can someone help me?

    The result in plain language should be:

    Select the year (deducted from 1 December), avg (temp) of weatherdata if date between 01-dec-current_year and 01-March-next_year.

    year - avg (temp)
    2010 - 5 (from December 2010 1 until March 1, 2011)
    2011. 1 of dec 1, 2011 until March 1, 2012)
    2012-3 from December 2012 1 up to March 1, 2013) will be in the future.

    Published by: dkoetsier on August 31, 2012 05:15

    I never suggested to the group only by reference. I geve suggestion you how to calculate the name of season. Of course, you also need this season belongs to which is:

    TO_CHAR (ADD_MONTHS (Datum,-2), 'YYYY')

    Here are the two pieces of data that must be grouped together. In order to obtain the average temperature in season:

    select  case to_char(add_months(datum,-2),'Q')
              when '1' then 'Spring'
              when '2' then 'Summer'
              when '3' then 'Fall'
              else 'Winter'
            end || ' of ' || to_char(add_months(datum,-2),'YYYY') season,
            avg(temp)
      from  weerdata
      group by to_char(add_months(datum,-2),'YYYY'),
               to_char(add_months(datum,-2),'Q')
    /
    

    SY.

  • Can I do a meeting maker that gives participants the possibility to choose from two dates to attend the event?

    I send a manufacturer of meeting staff and would they be able to choose one of the two dates to be trained. Is this possible without the separate meeting decision makers?

    Sorry, who is not related to Firefox. Seek assistance on the site to help with this program.

    Firefox 3.5.2 is a version of Firefox does not support, you need to update.

    http://www.Mozilla.com/en-us/Firefox/

  • will choose the manually back option in iTunes backup everything that is on my iPhone to my computer? Including the app data

    Not a problem just a question. I intend to sell my apple iPhone, it's not compatible with my new wireless network. I can't afford to buy an iPhone outright at the moment, but I plan in the future. I want to backup everything on my iPhone to my Mac so that I can restore the data to a new iPhone later. The current iPhone 5 is already set to save important things to iCloud, if I choose the option with a manual backup encryption will be that record everything, including all the data from the app? Sorry if this is a stupid question, I want to just make sure I have everything before you send the iPhone.

    Hello CallRinny,

    I understand that you have a question about your iTunes backups and that you should use. Back on which covers.

    In general, an iTunes backup will cover pretty much everything on your iPhone. The best thing to watch over it, it's what doesn't iTunes back upwards and which covers the encrypted backup. Take a look at the information below to clarify this. I would also do that applications will be recorded in your iTunes library, so when you restore your backup, apps will sync back to the wire in one sitting instead to download on the App Store.

    On safeguards in iCloud and iTunes
    https://support.Apple.com/en-us/HT204136

    backup iTunes

    On your Mac or PC, you can make a backup of your device in iTunes. Synchronize your device with your computer is not the same as performing a backup.

    An iTunes backup includes almost all settings and data from your device. An iTunes backup does not include:

    • Content of the iTunes and App Store or directly downloaded from iBooks PDF files (you can save this content using transfer purchases in iTunes.)
    • Synchronized content from iTunes, as imported MP3s or CDs, videos, books and photos
    • Photos already stored in the cloud, like My Photo Stream and iCloud photo library
    • Tap Settings ID
    • Settings and information Apple pay
    • Data activity, health, and keychain (to save this content, you will need to use iTunes backup encrypted ).

    Learn How to perform backups in iTunes, how to find them on your Mac or PC, and how to delete backups you no longer need.

    Let me know if this clears it for you.

    Take care

  • Choose the platform correct blackberry 10 for the use of functions such as call history, use of data, message records

    I want to design a blackberry 10 application that can fetch all call logs, data internate, messages through the application usage. Please help me choose the right platform that can provide all the APIs that are required for this application. 10 webworks Blackberry and Android runtime dosen't supports all API.

    Thank you.

    You can watch here

    https://developer.BlackBerry.com/native/documentation/Cascades/device_platform/invocation/invoking_c...

  • Disk groups are not visible cluster. vSAN datastore exists. 2 guests (on 8) cluster do not see the vSAN data store. Their storage is not recognized.

    http://i.imgur.com/pqAXtFl.PNG

    http://i.imgur.com/BnztaDD.PNG

    Do not know how even tear it down and rebuild it if the disk groups are not visible. The discs are in good health on each host storage adapters.

    Currently the latest version of vCenter 5.5. Hosts running 5.5 build 2068190

    Just built. Happy to demolish and rebuild. Just do not know why it is not visible on the two hosts and the disk groups are only recognized 3 guests when more are contributing. Also strange that I can't get the disk groups to fill in vCenter. I tried two different browsers (chrome and IE).

    I have now works.

    All the identical 5.5 relies on ESXi hosts. All hosts are homogeneous CPU/sum of the prospects for disk controller / installed RAM/storage.

    I have work. I had to manually destroy all traces of the vSAN on each single to help host node:

    (1) put the hosts in maintenance mode and remove the cluster. I was unable to disable vSAN in the cluster, I made on each node host (manually via the CLI below) then disconnected web client vCenter and return to finally refresh the ability to disable on the cluster.

    esxcli vsan cluster get - to check the status of each host.

    esxcli vsan cluster drop - the vSAN cluster host.

    storage of vsan esxcli list - view records in the individual host group

    esxcli vsan storage remove-d naa.id_of_magnetic_disks_here - to remove each of the disks in the disk group (you can ignore this using the following command to remove the SSD only falling each disc in this host group).

    esxcli vsan storage remove s naa.id_of_solid_state_disks_here - this is the SSD and all the magnetic disks in a given disk group.

    After that, I was able to manually add hosts to the cluster, leave maintenance mode and configure the disk groups. Aggregated data of the vSAN data store is correct now, and everything is functional.

    Another question for those of you who still read... How to configure such as the VM storage strategy that migrates towards (or inspired) the vSAN data store will immediately resume the default storage policy, I built for VSANs?

    Thanks for anyone who has followed.

  • Choose the date of the table

    Hello

    It comes to my table
    CREATE TABLE TEMP_LEAP
      (
        "DATE_FROM" DATE
      )
    Insertion of the data in it with the procedure which takes 2 parameters of date format:
    CREATE OR REPLACE
    PROCEDURE  "T_PROC" (p_dat_from date, p_dat_to date) IS
    BEGIN
    
    
    DECLARE
    
      day       number     := 0;
      st           NUMBER := 0;
    
    BEGIN
    
    day := p_dat_to+1 - p_dat_from; 
    
    for p in 1 .. day     
               
    loop   
                    
       insert into temp_leapp (date_from) values (p_dat_from+st);    
                    
        st := st+1;  
                  
    end loop;  
               
     commit; 
    END;
    END;
    Now lets fill in the data in the table:
    execute T_PROC(TO_DATE('01.01.2010','DD.MM.YYYY'),TO_DATE('17.08.2013','DD.MM.YYYY'));
    Data are now filled in the table.

    I want to do is do a select statement that will make the following output data:
    01.01.2010 - 31.12.2011
    01.01.2012 - 31.12.2012
    01.01.2013 - 17.08.2013
    I want is to get the leap year if there is a. I only need of days in the year, so don't mind the months.

    I need to check if there is a leap year in considering the p_dat_from and p_dat_to.

    If it isn't then you will get a single record of our instruction select and values will be made of: p_dat_from - p_dat_to.

    If there is a leap year in our period we will arrive after statements (example above).

    01.01.2010 - 31.12.2011 <-first date is p_dat_from and second is the last day before the leap year
    01.01.2012 - 31.12.2012 <-this is leap year. First date is the beginning of the leap year and the last date is the end of the leap year or p_date_to (if it ends in leap years).
    01.01.2013 - 17.08.2013 <- and this is the period after the leap years.

    It is a piece of code that I fell or with up to now:
    SELECT
    MIN(date_from),
    MAX(date_from)
    FROM temp_leap
    WHERE remainder(to_number(to_char(date_from,'yyyy')),4) = 0
    union
    
    SELECT 
    
    MIN(date_from) over (partition by to_char(date_from,'yyyy')),
    MAX(date_from) OVER (PARTITION BY to_char(date_from,'yyyy'))
    FROM temp_leap
    WHERE remainder(to_number(to_char(date_from,'yyyy')),4) <> 0
    
    ORDER BY 1,2;
    OK, that's all. I hope that its understandable that I do.
    If you have a questions please ask away.

    PS is there anything I need to do. You don't have to bother with the questions "what i February is after before etc." I don't love about it. All the other logic is already fixed all I need is what I wrote above.

    Thank you.

    Published by: BluShadow on March 14, 2013 08:24
    Fixed barcode labels

    Here's a way...

    SQL> create table temp_leap(date_from DATE)
      2  /
    
    Table created.
    
    SQL>
    SQL> insert into temp_leap
      2  select date '2010-01-01' + rownum - 1
      3  from dual
      4  connect by rownum <= (date '2013-08-17' - date '2010-01-01') + 1
      5  /
    
    1325 rows created.
    
    SQL>
    SQL> commit
      2  /
    
    Commit complete.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select min(date_from)||' - '||max(date_from)
      2  from
      3        (select date_from
      4              ,sum(leap_yr_switch) over (order by date_from) as leap_yr_switch_cnt
      5        from (
      6              select date_from
      7                    ,case when lag(leap_yr) over (order by date_from) != leap_yr then 1 else 0 end as leap_yr_switch
      8              from (
      9                    select date_from
     10                          ,case when mod(to_number(to_char(date_from,'YYYY')),400) = 0
     11                                 or (    mod(to_number(to_char(date_from,'YYYY')),4) = 0
     12                                     and mod(to_number(to_char(date_from,'YYYY')),100) != 0
     13                                    )
     14                           then 1 else 0 end as leap_yr
     15                    from temp_leap
     16                   )
     17             )
     18       )
     19  group by leap_yr_switch_cnt
     20* order by min(date_from)
    SQL> /
    
    MIN(DATE_FROM)||'-'||MAX(DATE_FROM)
    -------------------------------------------
    01-JAN-2010 00:00:00 - 31-DEC-2011 00:00:00
    01-JAN-2012 00:00:00 - 31-DEC-2012 00:00:00
    01-JAN-2013 00:00:00 - 17-AUG-2013 00:00:00
    

    Published by: BluShadow on March 14, 2013 08:51
    a slight correction in the calculation of the leap year, forgotten 100 years being does not leap.

  • When I buy Creative Cloud, can I choose the date when my 1 year subscription starts?

    Then it starts on the date of purchase creative cloud or can I choose the date beginning myself, for example 2 months after I bought initially creative cloud?

    It starts as soon as Adobe responds to your order. In practice, the date that Adobe receives your first payment.

    I've never seen an option to offer a start date.

    Using creative cloud | Creative cloud / Common Questions

    When does my membership start?

    If you purchase your membership directly from Adobe's Web site, it starts as soon as the order is respected by the Adobe Store. First connect to your account.

    If you buy your individual membership to a participating retailer or an online store, it starts as soon as you enter your purchase on creative.adobe.com and click on Get Started.

    If you buy a membership to team from a reseller, the terms of membership begins when you add seats to your account.

  • Problem to apply conditions to the cuurent group - model of implementation of the RTF data

    Hi all

    Here is my example of XML data generated by the report:

    < DATA >
    < DT >
    < CORPORATION >
    Vision of < NAME > < / NAME >
    < EMPLOYEE >
    < EMPNO > 6 < / EMPNO >
    Walker Rich < ENAME > < / ENAME >
    CLERK of < JOB > < / JOB >
    < SAL > 100 < / SAL >
    < Dept > IT < / Dept >
    < / EMPLOYEE >
    < EMPLOYEE >
    < EMPNO > 5 < / EMPNO >
    Russ Kepel < ENAME > < / ENAME >
    CLERK of < JOB > < / JOB >
    < SAL > 100 < / SAL >
    < Dept > ACCNT < / Dept >
    < / EMPLOYEE >
    < / COMPANY >
    < /DT >
    < Main_XML >
    rowset <>
    Department < and >
    < Dept > IT < / Dept >
    < DName > Information technology < / DName >
    < Text > welcome to the Dept IT < / text >
    < / Department >
    < / LINES >
    rowset <>
    Department < and >
    < Dept > ACCNT < / Dept >
    Accounting < DName > < / DName >
    < Text > welcome to the accounting department < / text >
    < / Department >
    < / LINES >
    < / Main_XML >
    < / DATA >


    I would need to create a rtf model to display the following for all employees:

    EmpNo
    Ename
    Job
    SAL
    Name of Dept
    text

    Here is the design of rtf, I created which is does not give me the desired result:

    <? for-each-group: USED; / EMPNO? >
    EMP: EMPNO
    ENAME
    JOB
    SAL
    Dept
    <? for-each - group:current-group(); / Dept? >
    <? If: Dept = Dept? >
    DName
    Text
    <? end if? >
    <? end for each group -? >
    <? end for each group -? >

    Please guide me how can I apply a condition to the previous group data in the current group. Thanks in advance.

    Try this:

    Declare a variable external/first group

    You can get rid of the second group and insert the DName field under Dept field and modify the code to include the following:

    Insert the text field and modify the code to include the following:

    Thank you
    BIPuser

Maybe you are looking for