Please help me with this request - I'm trying with Dense rank

version 10g

I got a quote for an account. If the same quote is received under different account I should mark the old account has received as being deleted.
Please help me.
/* Formatted on 2010/06/28 14:13 (Formatter Plus v4.8.8) */
WITH temp AS
     (SELECT '1-11TWQL' quote_id, 'COPS' ACCOUNT, 'Ordered' status,
             TO_DATE ('12/23/2009 3:37:54',
                      'mm/dd/yyyy hh:mi:ss PM'
                     ) captured_date
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'RFS',
             TO_DATE ('12/23/2009 3:37:50', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'Rejected',
             TO_DATE ('12/23/2009 3:37:52', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:51', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Ordered',
             TO_DATE ('12/23/2009 3:04:24', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'RFS',
             TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Rejected',
             TO_DATE ('12/23/2009 3:04:22', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Validated',
             TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'RFS',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'RFS',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8Z', 'COPS', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL
      UNION ALL
      SELECT '1-249A8Z', 'COPS', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
        FROM DUAL)
SELECT   quote_id, ACCOUNT, status, captured_date,
         DENSE_RANK () OVER (PARTITION BY quote_id ORDER BY quote_id,
          ACCOUNT) rn
--         ,CASE DENSE_RANK () OVER (PARTITION BY quote_id ORDER BY quote_id,
--              ACCOUNT)
--            WHEN 1
--               THEN 'Y'
--            ELSE 'N'
--         END deleted_flag
    FROM temp
ORDER BY quote_id, captured_date;
power required
WITH temp AS
     (SELECT '1-11TWQL' quote_id, 'COPS' ACCOUNT, 'Ordered' status,
             TO_DATE ('12/23/2009 3:37:54',
                      'mm/dd/yyyy hh:mi:ss PM'
                     ) captured_date, 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'RFS',
             TO_DATE ('12/23/2009 3:37:50', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'Rejected',
             TO_DATE ('12/23/2009 3:37:52', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:51', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Ordered',
             TO_DATE ('12/23/2009 3:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'RFS',
             TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Rejected',
             TO_DATE ('12/23/2009 3:04:22', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-11TWQL', 'D1', 'Validated',
             TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'RFS',
             TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Rejected',
             TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'COPS', 'Validated',
             TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'RFS',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'RFS',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8X', 'D1', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8Z', 'COPS', 'Validated',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL
      UNION ALL
      SELECT '1-249A8Z', 'COPS', 'Ordered',
             TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
        FROM DUAL)
SELECT   quote_id, ACCOUNT, status, captured_date, deleted_flag
    FROM temp
ORDER BY quote_id, captured_date;

This gives a shot:

SELECT quote_id
     , account
     , status
     , captured_date
     , CASE
            WHEN account_cnt  = 1
              OR account     != first_account
            THEN 'N'
            ELSE 'Y'
       END                                     AS deleted_flag
FROM
(
  SELECT quote_id
       , account
       , status
       , captured_date
       , FIRST_VALUE(account) OVER (PARTITION BY quote_id ORDER BY captured_date) AS first_account
       , COUNT(DISTINCT account) OVER (PARTITION BY quote_id) AS account_cnt
  FROM   temp
)
ORDER BY quote_id, captured_date;

Tags: Database

Similar Questions

  • The address bar where I can type in the Web addresses does not appear on my Mozilla, please help me with this... How to activate it?

    The address bar where I can type in the Web addresses does not appear on my Mozilla, please help me with this... How to activate it?

    Hi kdwis,

    Going to try view > toolbars and activation of the Bar of Navigation and in the bookmarks toolbar.

    Hope this helps!

  • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    Ideas:

    • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    I tried to download the RegCure as advised, but the problem still exists...

    Who advised you to 'download... '. RegCure? Doing so could only worse issues! If you ever think that your registry database must be cleaned, repaired, boosted or optimized (it isn't), read http://aumha.net/viewtopic.php?t=28099 and draw your own conclusions.

    See http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/6e716883-7af4-4a9f-8665-2f4dd57eee8d ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • This question is about programming in C. you please help me with a question that is.

    This question is about programming in c. can you please help me with an issue that is -

    Why do we write - printf ("r = c = %d %d sum = %d\n", sum c, r,);

    What we're trying to accomplish here by writing this.

    I also wanted to know why we write things within double quotes.

    The book programming in C I have, gave no information on this subject.

    The way if statements can be nested, of same whiles and fors can

    also be nested. To understand the nested loops how to work, watch the

    program below:

    / * Demonstration of nested loops * /.

    (main)

    {

    int sum c, r,

    for (r = 1; r<= 3="" ;="" r++="" )="" outer="" loop="">

    {

    for (c = 1; c<= 2="" ;="" c++="" )="" inner="" loop="">

    {

    sum = r + c;

    printf ("r = c = %d %d sum = %d\n", sum c, r,);

    }

    }

    }

    When you run this program, you will get the following result:

    r = 1 c = 1 sum = 2

    r = 1 c = 2 sum = 3

    r = 2 c = 1 sum = 3

    r = 2 c = 2 sum = 4

    r = 3 c = 1 sum = 4

    r = 3 c = 2 sum = 5

    In short, in C, a string enclosed in double quotation marks is replaced by a pointer to character to this string somewhere in memory.  The first parameter of a call to printf() is a pointer to the format string and the following parameters replace the % {(quoi que) the characters that appear in the format string.}  %d represents a whole argument of printing.

    HTH,

    JW

  • BlackBerry smartphones please help me with this indicator on my screen... it has reduced the quality of the voice

    Please help me with the rectangular symbol on the top next to the speaker symbol. It seems that I turned on an option by mistake, and whenever I've make or receive a call, this symbol appears. This was not the case previously.

    For this reason, my voice call quality has declined considerably. Please help quickly.

    Thank you

    itsmits

    Of course, he was told here in the forums of many times.

    It's the Audio Boost indicator call.

    To change, press your green numbering > Menu key > Enhanced Audio Boost.

  • Hello, I have version Adobe Acrobat 11. I have complete documents and send them to customers. However, when customers open the documents on their side, they are empty. The filled information are missing. Can you please help me with this problem?

    Hello, I have version Adobe Acrobat 11. I have complete documents and send them to customers. However, when customers open the documents on their side, they are empty. The filled information are missing. Can you please help me with this problem?

    Why are publish you again? You must first answer the question I ask in your original thread.

  • Please let me know how I can add a new column with a constraint not null, table already has data, without falling off the table... Please help me on this issue...

    Hello

    I have an emp_job_det with a, b, c columns table. Note that this TABLE ALREADY has DATA OF THESE COLUMNS

    IAM now add a new column "D" with forced not null

    Fistly I alter the table by adding the single column "D", if I do, the entire column would be created with alll of nulls for the column DEFAULT D

    ALTER table emp_job_det Add number D; -do note not null CONSTRAINT is not added

    Second... If I try to add the constraint not null, get an eoor as already conatained null values...

    (GOLD)

    In other words, if I put the query

    ALTER table emp_job_det Add number D NOT NULL; -THROWS ERROR AS TABLE ALREADY CONTAINS DATA

    So my question is how how can I add a new column with a constraint not null, table already has the data, without falling off the table

    Please help me on this issue...

    Add the column without constraint, then fill the column. Once all the rows in the table are given in the new column, and then add the constraint not null.

  • HP ENVY m6-1104se Notebook PC: Please help I want this driver on Windows 7-64 bit

    Hello
    I want to help this AMD 7670 M 2 GB driver
    I can't find the driver for windows 7-64 bit
    Portable model...
    HP ENVY m6-1104se Notebook PC
    I want to get on this driver for Windows 7-64 bit
    Please help I want this driver on Windows 7-64 bit

    Hello:

    You need the graphics driver, and it will also install the graphics card intel too.

    This package provides the AMD graphics driver high definition (HD) and Catalyst Control Center for models of laptop computers that are running an operating system supported. For laptops equipped with switchable graphics modes, this package contains the drivers for the two graphics (GPU). Switchable graphics allow users to switch between a graphical power mode (normally used under the power of the battery) and a mode of graphics performance. If the video output high-definition multimedia interface (HDMI) is supported, this package also installs the HDMI Audio Driver.

    File name: sp56948.exe

  • Could someone please help me with a problem I'm having with my update s/ie window?

    I was trying to find a way to get help with my concern about internet/window update of. 99% of the time when I'm in train to get updated window or check the mails on yahoo and a few other sites, my page is immediately closed. I tried to delete the cookies and files and restarted and system restore and reset my IE as well. Nothing works, and I know that I need some updates (would be nice to be able to check my email yahoo also).

    This is what happens in detail:

    I type in the Web site window update and as soon as he gets it closes immediately. When I type in the website of yahoo and then click check mail it closes immediately. There were a few other sites, but these are the 2 most important for me. I have no error code and no warning, just boom that it is gone and everytime I try to bring everything back up, it closes. I did everything I could and I am at a loss.

    Could someone please help me if I can get things and finally be happy and not so stressed. This happened for some time now. I tried to contact technical support, but I can't ever get a straight when clicking we answer contact as normal websites don't. So I try here.

    Please help me solve this problem... also I "think" I have IE 8? could be 7, but I think that 8. I can't because it messes up my computer.

    Thanks, I look forward to talk to someone soon then.

    Catt

    You probably have a nasty malware infection.

    In case you are unable to solve this problem with the suggestions of others, I think you should choose interactive free aid to this page:
  • When I try to defrag, a window opens and closes and a file download-security warning. A loop repeats. Other programs to do the same thing. Please help me fix this loop? SOS?

    When I run defrag, an IE window opens and closes and a file download-security warning comes up and asks me to run or save the file name: c:\windows\system32 dfrgui.exe, if I hit then another warning of IE - sec stands up and says 'the Publisher could not be verified. Are you sure that you want to run. I struck and the loop repeats. I run a diag of the F10 boot menu with dell. They say that its software and non-material, pay! Microsoft says that Dell is responsible. Other programs to do the same thing. I've updated and rerun my AVG security without error. We are automatically updated, and no other programs were added. Please help me fix this loop? SOS?

    Vista - open file - security warning
    http://www.Vistax64.com/Vista-security/125044-open-file-security-warning.html

    How to repair the operating system and how to restore the configuration of the operating system to an earlier point in time in Windows Vista
    http://support.Microsoft.com/kb/936212/#appliesTo

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/default.aspx/KB/929135

    Your programs launch properly from Safe Mode?  Or Normal Mode if you create another user to test with?

    Vista advanced boot options
    http://Techblissonline.com/Vista-advanced-boot-options/

    Try running ChkDsk to check your drive for errors. Right click on your drive icon / properties / tools / error checking.  Try first by checking do not each box (that it will run in read-only mode) to see if it reports any problems file or hard drive.  If so, restart it by checking both boxes and restart to allow him to attempt to fix any problems found.

    I see a lot of recommendations here for programs such as -

    Malwarebytes' Anti-Malware
    http://www.Malwarebytes.org/MBAM.php

    SuperAntispyware
    http://SUPERAntiSpyware.com/

  • BlackBerry Smartphones please help me with my BB Storm 2

    Hi fellow messengers,.

    I'm having a problem with my BB browser. My unit is BB Storm2 9550.  My browser does not work everytime I visit a particular site. He tells me that I am currently on a service plan that requires a WiFi connection. However, I am connected to Wifi. Wifi works really well. My friends are able to browse using the connection with their own phones. He also tells me that I am connected to Wifi, but my browser tells me that am not.  I only feel it now and its bothers me for two days. Ive tried another wifi spot, but then I always get the same problem.

    The strange thing is that whenever I'm

    in my FB app (via my social BB connection), and then I decided to press the option that says go to FB Mobile, there is no problem. I know what his FB mobile, it works only if you are connected to WIFI. And Yes, it worked for me. But, when I go to the browser and type the domain, www.google.com, it never worked...

    Please help me solve this problem.

    Thank you!

    Just checkin, OK?

    My dear sweet companions experts have been berating me for a long time wandering on several of my links... (Hellllooo... BIFOCALS?  )

    I have a 9550 Storm so please open your browser, press the menu key > options > cache operations and everything clear.

    Back to Homepage > main menu options > list your options of confutation of browser, even for General properties.

    If we cannot see an anomaly in software we can make (Advanced) WIFI diagnostics and diagnostic of Mobile phone network services,

    Thank you

    Bifocals

    KB13299 Use the tool of diagnosis Wi - Fi (advanced only)

    BlackBerry Storm2 Series - 5.0 - user - 292 Guide

    Your mobile network diagnostic

    Now your answer is here at the end, but you should really keep

    cleaning of ordinary memory, service books, etc.

    Have a great day!

    KB14394 When you try to access a web site on the BlackBerry smartphone, the following error message appears: "this is a Wi - Fi service. Please make sure that your device is equipped with an active WiFi connection and try again. »

  • Please help me with my dv6t 1200 cto

    I want to install win xp on my 1200cto dv6t.

    I read the post (general Guide for XP Downgrade for HP/Compaq Notebook consumer)

    It's really very very useful...

    But the links for the sata drivers for intel does not work with me.

    ((For laptop with Intel processors installed, use in ICH9 sata driver,

    The pilot is located in iaAHCI.inf and is called ICH9M-E/M SATA AHCI Controller here))

    When I press the last link for intel, it transfers me to the site intel with error message saying that (( download is not available

    This download is no longer available))

    Please help me solve this problem.

    Thanks in advance

    So sorry for the link, Cheryl may have some difficuties updated the link.

    Intel has updated their drivers, old link has been removed.

    ICH9M-E/M SATA AHCI Controller, here

    Good luck

  • Please help me with the issue of the image

    Hello

    I need to create a report of error log which two same named images overlapped together.

    Screen Shot 2015-12-16 at 1.01.06 PM.png

    The image above shows how is my page indesign file. I need the report as error log:

    With overlapping of images: photo_sample3.jpg

    Logic:

    I don't know what logic I need to use to get there. But with my knowledge, I thought, I can use the image name and the value of geometric image to achieve. I found a script that gives the number duplication, if any of this page in this page of this forum.

    var overlapArray = new Array();  
    var myPages = app.activeDocument.pages.everyItem().getElements();  
      
    for(i=0; i<myPages.length; i++)  
    {  
        var myPgItems = myPages[i].allPageItems;  
        for(k=0; k<myPgItems.length; k++)  
        {  
         var bounds1 = myPgItems[k].geometricBounds;  
                for(j=0; j<myPgItems.length; j++)  
                     {  
                       var bounds2 = myPgItems[j].geometricBounds;  
                         if(k==j)  
                         {  
                             continue;  
                         }  
                        var temp = touches(bounds1, bounds2);                     
                        if(temp == true)  
                        {  
                            overlapArray.push(myPages[i].name)  
                        }  
                 }  
             }  
     }  
    alert("overlap Pages: "+overlapArray);  
      
    function touches(bounds1, bounds2)  
    {  
    if (bounds1[2] < bounds2[0]) return false;  
    if (bounds1[0] > bounds2[2]) return false;  
    if (bounds1[1] > bounds2[3]) return false;  
    if (bounds1[3] < bounds2[1]) return false;  
      return true;  
    }   
    

    Please help me with script or logic.

    Thank you in advance,

    Kitty

    Hi well,.

    all was needed was a line of code

    Array.prototype.intersect = function ( coordinates ) {
        var n = this.length;
        var nY1, nX1, nY2, nX2;
        var y1 = coordinates[0];
        var x1 = coordinates[1];
        var y2 = coordinates[2];
        var x2 = coordinates[3];
    
        while ( n-- ) {
            nY1 = this[n][0];
            nX1 = this[n][1];
            nY2 = this[n][2];
            nX2 = this[n][3];
    
            if (
                (
                    ( y1>=nY1 && y1<=nY2 )
                    &&
                    (x1>=nX1 && x1<=nX2 )
                )
    
                ||
    
                (
                    ( y2>=nY1 && y2<=nY2 )
                    &&
                    (x2>=nX1 && x2<=nX2 )
                )
    
            ){
                return true;
            }
        }
    
        return false;
    }
    function reportOverlaps() {
        var doc,gs, g, n, o = {}, p, pg, pb, lk, lkn, overlaps = [];
    
        if (!app.documents.length) return;
    
        doc = app.activeDocument;
    
        gs = doc.allGraphics;
    
        n = gs.length;
    
        while ( n-- ) {
            g = gs[n];
            p = g.parent;
            pg = p.properties.parentPage;
            if ( pg instanceof Page ) {
                pb = p.visibleBounds;
    
                lk = g.itemLink;
                lkn = lk.name;
    
                if ( !o[pg.name] ) {
                    o[pg.name] = o[pg.name] || {};
                }
    
                if ( !o[pg.name][lkn] ) {
                    o[pg.name][lkn] = o[pg.name][lkn] || [];
                    o[pg.name][lkn][ o[pg.name][lkn].length ] = pb;
                }
                else {
                    var intersect = o[pg.name][lkn].intersect ( pb );
                    intersect && overlaps[ overlaps.length ] = "Pg:"+pg.name+"//"+lkn;
                    o[pg.name][lkn][ o[pg.name][lkn].length ] = pb;
                }
            }
        }
    
        alert( overlaps.length? "Following overlaps where found:\r"+overlaps.join('\r' ) : "No overlaps found" );
    }
    
    reportOverlaps();
    

    Loïc

    www.ozalto.com

  • Please help me write this SQL query...

    Hi everyone,
    
    Please help me in this query.
    A patient can multiple types of Adresses (types P,M,D).If they have all the 3 types i need to select type: p and
    if they have (M and D) i need to select type M,and if they have only type D i have to select that.
    For each address i need to validate whether that particular address is valid or not (by start date and end date and valid flag)
    
    Patient table
    =============
    
    Patient_id          First_name    last_name
    
    1                   sanjay        kumar
    2                   ajay          singh
    3                   Mike          John
    
    
    Adress table
    ============
    
    address_id       patient_id       adresss       city       type       startdate        enddate      valid_flg
    
    1                   1             6222         dsadsa           P          01/01/2007       01/01/2010
    2                   1             63333        dsad             M          01/02/2006       01/01/2007      N
    3                   1             64564         fdf              M          01/01/2008       07/01/2009      
    4                   1             654757       fsdfsa          D          01/02/2008       09/10/2009  
    5                   2             fsdfsd       fsdfsd            M          01/03/2007       09/10/2009   
    6                   2             jhkjk        dsad              D          01/01/2007       10/10/2010   
    7                   3             asfd         sfds               D          01/02/2008       10/10/2009      
    
    
    output
    =====
    
    1        sanjay       kumar            6222       dsadsa      P          01/01/2007        01/01/2010     
    2        ajay         singh            fsdfsd     fsdfsd       M          01/03/2007        09/10/2009 
    3        mike         john              asfd       sfds        D          01/02/2008        10/10/2009
    Thanks in advance
    Phani

    Hello, Fabienne,.

    This race for you (twisted code of Sarma):

    SELECT patient_id, first_name, last_name, address, city, type, startdate, enddate
     FROM (
      SELECT a.patient_id patient_id, first_name, last_name, address, city, type, startdate, enddate,
                 ROW_NUMBER() OVER (PARTITION BY p.patient_id ORDER BY CASE type WHEN 'P' THEN 1
                                                                          WHEN  'M' THEN 2
                                                                          WHEN  'D' THEN 3
                                                                        END) rn
        FROM  patient p
        JOIN  address a ON (p.patient_id = a.patient_id )
       WHERE NVL(valid_flg, 'X') != 'N'
         AND SYSDATE BETWEEN startdate AND  NVL(enddate, SYSDATE)
         )
    WHERE rn = 1; 
    

    Edit, currently in the trial:

    With Patient AS (
    SELECT 1  Patient_id , 'sanjay' First_name, 'kumar'  last_name FROM DUAL UNION ALL
    SELECT 2, 'ajay', 'singh' FROM DUAL UNION ALL
    SELECT 3, 'Mike', 'John' FROM DUAL),
    Address AS (
    SELECT 1   address_id, 1  patient_id, '6222'    address, 'dsadsa'   city, 'P'  type, to_date('01/01/2007', 'DD/MM/YYYY')  startdate, to_date('01/01/2010', 'DD/MM/YYYY')  enddate, NULL  valid_flg FROM DUAL UNION ALL
    SELECT 2,1,'63333','dsad','M', to_date('01/02/2006', 'DD/MM/YYYY'), to_date('01/01/2007', 'DD/MM/YYYY'),  ' N'  FROM DUAL UNION ALL
    SELECT 3,1,'64564','fdf','M', to_date('01/01/2008', 'DD/MM/YYYY'), to_date('07/01/2009', 'DD/MM/YYYY'), NULL  FROM DUAL UNION ALL
    SELECT 4,1,'654757','fsdfsa','D', to_date('01/02/2008', 'DD/MM/YYYY'), to_date('09/10/2009', 'DD/MM/YYYY'),  NULL  FROM DUAL UNION ALL
    SELECT 5,2,'fsdfsd ','fsdfsd','M', to_date('01/03/2007', 'DD/MM/YYYY'), to_date('09/10/2009', 'DD/MM/YYYY'), NULL  FROM DUAL UNION ALL
    SELECT 6,2,' jhkjk','dsad','D', to_date('01/01/2007', 'DD/MM/YYYY'), to_date('10/10/2010', 'DD/MM/YYYY'),  NULL  FROM DUAL UNION ALL
    SELECT 7,3,'asfd',' sfds',' D', to_date('01/02/2008', 'DD/MM/YYYY'), to_date('10/10/2009', 'DD/MM/YYYY'),  NULL  FROM DUAL)
    -- end test data
     SELECT patient_id, first_name, last_name, address, city, type, startdate, enddate
     FROM (
      SELECT a.patient_id patient_id, first_name, last_name, address, city, type, startdate, enddate,
                 ROW_NUMBER() OVER (PARTITION BY p.patient_id ORDER BY CASE type WHEN 'P' THEN 1
                                                                          WHEN  'M' THEN 2
                                                                          WHEN  'D' THEN 3
                                                                        END) rn
        FROM  patient p
        JOIN  address a ON (p.patient_id = a.patient_id )
       WHERE NVL(valid_flg, 'X') != 'N'
         AND SYSDATE BETWEEN startdate AND  NVL(enddate, SYSDATE)
         )
    WHERE rn = 1; 
    
    PATIENT_ID FIRST_ LAST_ ADDRESS CITY   TY STARTDATE ENDDATE
    ---------- ------ ----- ------- ------ -- --------- ---------
             1 sanjay kumar 6222    dsadsa P  01-JAN-07 01-JAN-10
             2 ajay   singh fsdfsd  fsdfsd M  01-MAR-07 09-OCT-09
             3 Mike   John  asfd     sfds  D 01-FEB-08 10-OCT-09
    
  • After updating my iPhone 6 (9.3.4) the WiFi signal becomes very low! I did everything, but the problem does not stop! I don't a not update my other devices &amp; their very good WiFi signals. Please help me solve this terrible problem...

    After updating my iPhone 6 (9.3.4) the WiFi signal becomes very low! I did everything, but the problem does not stop! I don't a not update my other devices & their very good WiFi signals. Please help me solve this terrible problem...

    Here's a tip for the user on the problems of Wi - Fi. Suggest from the top and bottom. Maybe one of them will help you.

    (1) restart you device.

    (2) resetting the network settings: settings > general > reset > reset network settings. Join the network again.

    (3) reboot router/Modem: unplug power for 2 minutes and reconnect. Update the Firmware on the router (support Web site of the manufacturer for a new FW check). Also try different bands (2.4 GHz and 5 GHz) and different bandwidths (recommended for 2.4 to 20 MHz bandwidth). Channels 1, 6 or 11 are recommended for 2.4 band.

    (4) change of Google DNS: settings > Wi - Fi > click the network, delete all the numbers under DNS and enter 8.8.8.8 or otherwise 8.8.4.4

    (5) disable the prioritization of device on the router if this feature is available. Also turn off all apps to VPN and retest the Wi - Fi.

    (6) determine if other wireless network devices work well (other iOS devices, Mac, PC).

    (7) try the device on another network, i.e., neighbors, the public coffee house, etc.

    (8) backup and restore the device using iTunes. Try to restore as New first and test it. If ok try to restore the backup (the backup may be corrupted).

    https://support.Apple.com/en-us/HT201252

    (9) go to the Apple store for the evaluation of the material. The Wi - Fi chip or the antenna could be faulty.

    Council: https://discussions.apple.com/docs/DOC-9892

  • Sir please help me with my home page. When I put my Home Page about: welcome it gives an error saying invalid Url... Please tell Me how to fix it!

    Question
    Sir please help me with my home page. When I put my Home Page about: welcome it gives an error saying invalid Url... Please tell Me how to fix it!

    Subject: House = without capital letters

Maybe you are looking for