Need to find the invalid coverage period

Hi gurus

I have the following data:

Table design

DROP TABLE cal_rules;
DROP TABLE cal_rules_dtl;
-------------------------------------
CREATE TABLE cal_rules
(
rule_id NUMBER (10),
effective_date DATE,
termination_date DATE);

CREATE TABLE cal_rules_dtl
(
rule_id NUMBER (10),
as_of_date DATE);
---------------------

Table insert
INSERT INTO cal_rules
(SELECT 100, to_date('01-JAN-2013') effective_date, to_date('31-DEC-2013') termination_date FROM dual
UNION ALL
200, to_date('01-JAN-2013') SELECT effective_date, to_date('31-DEC-2013') FROM dual
UNION ALL
SELECT 300, to_date('01-JAN-2013') effective_date, NULL FROM dual
UNION ALL
SELECT 400, to_date('01-JUN-2013') effective_date, to_date('31-DEC-2013') termination_date double
UNION ALL
SELECT 500, to_date('01-JUN-2013') effective_date, NULL FROM dual termination_date
UNION ALL
SELECT 600, to_date('01-JUN-2013') effective_date, to_date('31-DEC-2013') termination_date double
);
---------------
INSERT INTO cal_rules_dtl
(SELECT 100, to_date('02-JAN-2013') as_of_date FROM DUAL - GAP - IT SHOULD START WITH January 1, 2013)
UNION ALL
SELECT 200, to_date('01-JAN-2013') as_of_date FROM DUAL
UNION ALL
SELECT 200, to_date('05-JAN-2013') as_of_date FROM DUAL
UNION ALL
SELECT 200, to_date('01-JAN-2014') as_of_date FROM DUAL - AS_OF_dATE AFTER the TERMINATION_DATE(31-DEC-2013) CAL_RULES IS
UNION ALL
SELECT 300, to_date('31-DEC-2012') as_of_date FROM DUAL - IS BEFORE CAL_RULES AS_OF_DATE EFFECTIVE_DATE
UNION ALL
SELECT 400, to_date('01-JUN-2013') as_of_date FROM DUAL
UNION ALL
SELECT 400, to_date('31-AUG-2013') as_of_date FROM DUAL
UNION ALL
SELECT 500, to_date('01-JUN-2013') as_of_date FROM DUAL
UNION ALL
SELECT 500, to_date('01-JUL-2013') as_of_date FROM DUAL
UNION ALL
SELECT 500, to_date('01-SEP-2013') as_of_date FROM DUAL
UNION ALL
SELECT 500, to_date('01-OCT-2013') as_of_date FROM DUAL
UNION ALL
SELECT 500, to_date('01-OCT-2013') as_of_date FROM DUAL
UNION ALL
SELECT 600, to_date('10-JUN-2013') as_of_date FROM DUAL
UNION ALL
SELECT 600, to_date('01-JUN-2013') as_of_date FROM DUAL
);

COMMIT;

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

Power required

Rule_id Effective_date Termination_date

100 1st January 13 December 31, 13 - the gap because in the cal_rules_dtl table is as_of_date against this rule id January 2, 2013

200 January 1, 13 December 31, 13 - as_of_date against the id of rule 200 is superior to cal_rules.temination_date

300 1st January 13 null - as_of_date against the id of rule 30 is less than cal_rules.effective_date

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

Need to communicate their data using the following conditions:

If no matter what As_of_data less than effective_date (see rule_id 300)

If any higher than termination_date As_of_data (see rule_id 200)

If there is a gap between as_of_date and effective_date (see rule_id 100)

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

Please guide me and let me know if you have any questions. Thank you

I think that is not correct because there may be a line, for example

SELECT 100, to_date('05-JAN-2013') as_of_date FROM DUAL - GAP - IT SHOULD START WITH January 1, 2013

in your case with 100 rule ID will not be output for condition where d.as_of_date - effective_date = 1

I think OP wants this:

Select distinct q.rule_id, q.effective_date, q.termination_date of)
SELECT c.as_of_date, t.*,
min (c.as_of_date) over (partition by c.rule_id by c.as_of_date order lie between unbounded preceding and current line),
-case when (c.as_of_date! = t.effective_date and)
t.effective_date! (= min (c.as_of_date) over (partition by order of c.rule_id by c.as_of_date lie between unbounded preceding and current line))
or not (min (c.as_of_date) on (c.rule_id partition) between t.effective_date and t.termination_date)
or not (max (c.as_of_date) on (c.rule_id partition) between t.effective_date and t.termination_date)
then-1
end myRule
OF cal_rules t
Join the cal_rules_dtl c
On c.rule_id = t.rule_id
) q
where myRule = - 1

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • I have a seuillee image and I need to find the actual surface of the black region

    I have a seuillee image and I need to find the true field of the black region.iam new view.please guide me.i lab joined the image...


  • Need to find the correct reference for replacement screen Aspire 5742

    Hello

    I need to find the correct part for replacement screen Aspire 5742.  The backlight does not work anymore, and I already bought a UPS to see that this model/version does not use a UPS (as the backlight is LED and integrated in the element of the screen).  I find the somewhat confusing model numbers table.  The full model version seems to be:

    5742 - 464G50Mnnk

    S/N: [redacted to comply with guidelines]

    SNID [redacted to comply with guidelines]

    This seems to be a very good laptop that belongs to a mine Guigou, but not worth repair at the local dealership, and I'm sure I can replace the screen myself if I can get the right part, having already dismantled the set of sieves and to be an electronic engineer.

    Either way, I guess that this version of model is the 5742, not the 5742 G (even if the model number has a 'G' in it: some of the confusion).  Any help would be appreciated.

    Part numbers for the 15.6 TFT LCD for the Aspire 5742 are:

    LK.15605.004
    LK.15605.010
    LK.15606.009
    LK.15608.007
    LK.15608.011
    LK.1560A.004
    LK.1560D.010
    LK.1560E.004
    LK.15605.019
    LK.15606.012

  • The update to version 2 of Vitsa fail. Formatted hard drive to purchase the version. need to find the final vista product key

    The update to version 2 of Vitsa fail. Formatted hard drive to purchase the version. need to find the final vista product key

    It should be on a sticker on the box, or on the packaging.

    The product key consisted of 25 digits, divided into 5 groups of 5 digits.

    See you soon...

    Mick Murphy - Microsoft partner

  • I need to find the 32-bit version of bootsect.exe.

    Need the 32-bit version of bootsect.exe


    I need to find the 32-bit version of bootsect.exe.  I downloaded Windows 7 Pro 64-bit version of Digital River to upgrade my Dell Inspion Windows Vista Home Premium 32 bit.  I can't download boosect.exe from the Microsoft Store because I Win 7 through Digital River.  Where can I download this small file.  Someone has to have it.  Thank you.

    If you need the 32-bit version because you can't start download 64-bit here is how to make bootable download and install.

    Create installation DVD or Flash USB in Windows 7 download

    According to what you have downloaded (ISO or .box) and what you have available, you can use one of the links below to create bootable media. Use the methods of USB flash drive, your flash drive must be 4 GB or more. You could also buy the installation DVD if you wish.

    DVD from ISO - if you downloaded the ISO file use a burning program to a DVD. You can also use the USB/DVD Windows 7 download tool allows you to create a copy of your ISO of Windows 7 file on a flash drive, DVD or USB.
    http://store.Microsoft.com/help/ISO-tool
    http://pcsupport.about.com/od/toolsofthetrade/HT/burnisofile.htm

    DVDS from files .box - if you downloaded the. EXE &. Box follow these instructions to make a bootable from download Windows 7 DVD:
    http://www.TomsHardware.com/Forum/1392-63-Windows-upgrade-bootable-guide-having-issues

    USB Flash ISO - if you downloaded the ISO file and you want to install Windows 7 using a flash drive:
    Windows 7 USB/DVD Download tool allows you to create a copy of your ISO of Windows 7 file on a Flash DRIVE or a DVD. To create a bootable DVD or USB flash drive, download the ISO file and then run the Windows 7 USB/DVD Download tool. Once this is done, you can install Windows 7 directly from the Flash DRIVE or a DVD.
    http://store.Microsoft.com/help/ISO-tool

    USB stick installation files - WinToFlash is a practical application that will help you transfer your Windows 7 installation from a hard drive or DVD to USB flash in a few steps. That you can install Windows 7 from a flash card, USB stick, HDD, etc to your computer or netbook. If you have downloaded the .box file extract everything first. If you have a 4 GB or more large USB key (or external hard drive), and the computer can boot from USB:
    http://www.Softpedia.com/get/system/system-miscellaneous/WinToFlash.shtml

    Then:
    32-bit to 64-bit custom clean installation steps

    You can use a disk upgrade, but you cannot make a room upgrade from a 32-bit system on a 64-bit system, the only way is to do a custom clean install. This means that you will have to reinstall all your programs, but you can save your files and settings on an external storage before that with Windows Easy Transfer. According to Microsoft the following steps:

    1. start Windows Upgrade Advisor (http://windows.microsoft.com/en-US/windows/downloads/upgrade-advisor ) to see if there are known issues that may affect the installation and the question of whether you should install the version of 32 or 64 bit Windows 7.

    2 back up your files and settings. To avoid losing everything that you will need to save copies of all files, photos and other information that you want to keep an external hard drive. Windows Easy Transfer (http://windows.microsoft.com/windows-easy-transfer ) is a free tool that you can use to copy your information (but not programs) from your PC and then put them after installing Windows 7. If you do not have an external hard drive, you will not be able to use Windows Easy Transfer, instead you can copy the files you want to keep on a USB stick or CD/DVD.

    3. find the discs original installation and license/product keys associated to programs currently on your computer because you will have to manually reinstall your programs after installing Windows 7. You may be able to download programs from the Internet.

    4 Medallion the Windows 7 DVD in your PC, reboot, start of the DVD. When asked "which type of installation do you want?" click "Custom (advanced)."

    5. when Windows 7 is installed, you can use Windows Easy Transfer to restore your files & settings and use your installation diskettes to install all your programs.

    Questions about installing Windows 7?
    FAQ - Frequently Asked Questions from Installation Windows 7 & responses

  • Need to find the version number referring to the last name change for each emplid.

    emplIDName ageVersion
    --------   -----------
    1ABC252
    1ABC265
    1def279
    1def2815
    1def2918
    2JKL155
    2MNO168
    2MNO1711
    2PQR1820

    Need to find the version number referring to the last name change for each emplid.

    As indicated by the version number change when there is change in age as well, but I need a query that gives the version number referring to the last name change for each emplid.

    with

    DATA_TABLE (EmplId, Name, Age, version) as

    (select 1, 'abc', 25, 2 double Union all

    Select 1, 'abc', 26, 5 Union double all the

    Select 1, 'def', 27, 9 double Union all

    Select 1, 'def', 28, 15 double Union all

    Select 1, 'def', 29, 18 double Union all

    Select 2, 'jkl', 15 5 Union double all the

    Select 2, 'mno', 16, 8 double Union all

    Select 2, 'mno', 17, 11 double Union all

    Select 2, 'pqr', 18, 20 double

    )

    Select emplid,

    Max (Name) name of Dungeon (dense_rank last order by version).

    Max (Age) age of Dungeon (dense_rank last order by version).

    version Max (version)

    from (select emplid, name, version,)

    -case where name! = lag(name,1,name) on (emplid version order partition)

    then "renamed".

    end change

    of data_table

    )

    where the change is not null

    Emplid group

    EMPLID NAME AGE VERSION
    1 def 27 9
    2 PQR 18 20

    Concerning

    Etbin

  • I tried a trial version of lightroom 6 and edited hundreds of photots I need to find the export files are small non-printable, about 600 kbs. So I bought lightroom 6 hoping to save my changes on all the photos. However with my purchase of more than a week

    I tried a trial version of lightroom 6 and edited hundreds of photots I need to find the export files are small non-printable, about 600 kbs. So I bought lightroom 6 hoping to save my changes on all the photos. However with my purchase of more than a week, my picture exports are still about 600 kbs. Not printable! I'm signed and registered. Whats happening?

    Looks like you have been in the library module and chose with a preset export or export to email. Whatever it is, your Presets 'export' were to reduce the size of the image exported to about 600 k.

    In Lightroom, the library module and under the file menu, simply select the Word Export. Who will open another dialog box. GO through each option in this dialog box to choose where you want to export the file, what color space to use, what name to give to each folder, what metadata to include and do not forget to select the export size! I included a few screenshots for your reference.

    If you export exactly the same path several times, you can create your own export preset to make this process faster.

  • Need to find the Antivirus Program for beginning OSX 10.5.8

    Need to find an anti-virus program updated for OSX 10.5.8

    Desktop IMAC Intel Core 2 Duo 2.4 GHz 1 GB 800 MHz DDR2 SDRAM

    MOM is 86 with a touch of dementia, but still, she loves his Mac and he uses every day to read his newspaper and use Facebook. She cannot tolerate the change of operating system and it has an office with a limit of 1 GB memory. Norton support is no longer its OS after this month.

    Have you looked at other AVP and haven't found one that support this old BONE. I checked Kaspersky, Bitdefender and Intego, MacAffee with no luck.

    It is a prime target for phishers and other infamous trolls. Help, please. I'm in his State for today only and need to solve this problem. Thank you

    You don't need a virus scanner - there is no virus affecting the Leopard. And a virus program, even if you could find one, does nothing about phishing - it's a question of not no follow-up on the questionable links.

  • I need to find the SPAM folder. How can I do?

    In order to retrieve information on some sites, I need my password. They send my password, but they tell me to check the spam folder. Where can I find the spam folder? Designated as spam messages do not appear in my Inbox to the ordinary letters.

    Thunderbird does not create a Spam folder. Your email provider may have a. Sign in to your account to your web e-mail providers site and see what you find there.

    Thunderbird junk term instead of Spam used to separate things. By default, Thunderbird places an unwanted icon next to what anyone, he considers undesirable and place in your Inbox unless you go into unnecessary controls and change this operation. Looks like you have not done this.

  • Need to find the cmos on Satellite Pro 2100 battery

    I have a laptop that is not keep date/time settings and I need to identify the laptop to find the correct instructions to take apart.

    The brand is a Satellite Pro SP2100, model PS210E006P9-EN number, but I can't find this brand/model on the Toshiba site. The closest I can find is Satellite 2400-103, part number: PS240 - T 014, 1, that seems identical.

    I tried to use the identify tool of Toshiba to detect what is the laptop, but that fails to provide results.

    I also need to find out what food is for this unit as the current is defective and exposed wires.

    The adapter of current with her is PA3201U-1ACA, the problem is that this card has another card on the end to fit the power plug to the back of the laptop. The connector at the end of PA3201U is too thin to fit.

    Hello

    This laptop is very old and the name of this machine is: Satellite Pro 2100 PS210E

    > I have a laptop that is not keep date/time settings and I need to identify the laptop to find the correct instructions to take apart.

    Usually the CMOS battery can be charged. You must connect the power adapter and the laptop must be powered for about 12-14 hours.

  • need to find the Manager device in my laptop,

    I need to find a driver through the Device Manager, but dm nowhere is dor: to install a driver in my phone Android mobile phone.

    Make a right click my computer, and then click Properties.  Then click on Device Manager.

    I hope this helps.  Good luck.

  • Need to find the driver for HL-DT-DVDRA GH41NATA

    I have deleted or lost the driver for the disc drive.  He came on a Gateway computer and cannot download the gateway repair tools.  Need to find this driver.

    Original title: driver for HL - DT - DVDRA GH41NATA

    Hi Jim,.

    Thanks for posting your query in Microsoft Community.

    I understand that you need the driver for DVD drive for your Gateway computer.

    1. What is the model number of your computer?

    I suggest you go to the gateway support Web site to download and install the drivers for your computer.

    Please feel free to post if you have questions about Windows. We would be happy to help you at best.

  • Need help finding the product key.

    Here, can anyone help me find the product key of Norton antivirus software that came pre-installed with my hp Pavilion 15' inch laptop notebook pc. I need to update the software and I can't do it without the key.
    Impatient in waiting.

    If the product is installed (Norton _) - it would be better to contact them (Symantec / Norton) support - as it's their product and they will be able to tell you where to look.

    otherwise, you can try third-party products like Belarc Advisor - that should give you said information if it exists on the system.

  • Need to find the common number

    Need to find a common number among all of the calls:



    Create table call (key id Number (15) not null, mobile_number number primary (10), other_party number (10), call_type varchar2 (10), the call_date_time date, number (15)) duration;


    insert into values of the call (1,9818764535,9899875643, 'IN', to_date (24 April 13 02:10:43 "," dd-MON-yy hh24:mi:ss'), 10);
    Insert in appeal values (2, 9897451236,9899875643, 'OUT', to_date (April 28, 13 08:11:13 "," dd-MON-yy hh24:mi:ss'), 20);
    Insert in appeal values (3, 9899917277,9899875643, 'IN', to_date (30 April 13 18:07:02 "," dd-MON-yy hh24:mi:ss'), 30);
    insert into values of the call (4,9818764535,9215478213, 'IN', to_date (1 May 13 02:11:13 "," dd-MON-yy hh24:mi:ss'), 40);
    Insert in appeal values (5, 9899917277,9215478213, 'IN', to_date (1 May 13 08:17:02 "," dd-MON-yy hh24:mi:ss'), 25);
    Insert in appeal values (6, 9897451236,9012451785, 'OUT', to_date (1 May 13 20:21:04 ',' dd-MON-yy hh24:mi:ss'), 67);



    Query criteria:

    common calling to the list of numbers that is in contact with the listed numbers.

    Mobile_number entry:
    9818764535
    9897451236
    9899917277


    exit number common

    Mobile another numberlength part Date_Time

    9818764535 9899875643 24 APRIL 13 02:10:43 10
    9897451236 9899875643 28 APRIL 13 08:11:13 20
    9899917277 9899875643 30 APRIL 13 18:07:02 30

    Hello

    One way is to encrypt the target in a table game or result, as above, knapen don't:

    WITH    input_number     AS
    (
         SELECT  9818764535 AS mobile_number  FROM dual    UNION ALL
           SELECT      9897451236                   FROM dual    UNION ALL
           SELECT      9899917277                FROM dual
    )
    SELECT     *     -- or list columns wanted
    FROM     call
    WHERE     mobile_number     IN (SELECT  mobile_number  FROM  input_number)
    AND     other_party     IN (SELECT  mobile_number  FROM  input_number)
    ;
    
  • Need help finding the number of occurrences of a model.

    Hi all

    I need help to find the number of occurrences of a model in the column of the table data.

    Consider the examples of data - column of a row in a table:

    'S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C '.

    My requirement is:

    I should get the County of S that are immediately preceded by or P.

    for the above data, I should get are counted as 3 + 2 + 1 = 6 (S-S-S-A, S-S-P, S - A)

    The configuration data is stored as type VARCHAR2.

    Thanks in advance,
    Girish G

    Published by: Girish G on July 21, 2011 23:22

    I don't know that there is a better way, then this one:

    SQL> with dt as
      2  (select 'S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C' str from dual)
      3  SELECT SUM(Regexp_count(Regexp_substr(str, '(S\-?)+(A|P)+', 1,
      4                                     Regexp_count(str, '(S\-?)+(A|P)+') - (
      5                                                  LEVEL - 1 )), 'S')) len
      6  FROM   dt
      7  CONNECT BY LEVEL <= Regexp_count(str, '(S\-?)+(A|P)+')
      8  /
    
           LEN
    ----------
             6
    

Maybe you are looking for