Query taking a long time to run

Hello

I have a query that takes a long time to run. There are 191 000 records. This is static data only. This is the query.


SELECT X_FIRST_NAME,
X_LAST_NAME,
X_MIDDLE_NAME,
X_MEMBERSHIP_ID,
X_ASSOCIATE_ID,
X_MEMBER_KY,
X_MEMBER_EXP_DATE,
X_JOIN_CLUB_DATE,
X_MEMBERSHIP_KY,
X_ADDRESS1,
X_ADDRESS2,
X_CITY,
X_STATE,
X_ZIP,
X_DELIVERY_ROUTE

OF Canceled_Customers S
WHERE THERE ARE
(SELECT 'Y' FROM Canceled_Customers WHERE)
(By SELECTING COUNT (P.X_MEMBERSHIP_KY) IN Canceled_Customers P)
WHERE P.X_ADDRESS1 = S.X_ADDRESS1
AND P.X_ADDRESS2 = S.X_ADDRESS2
AND P.X_CITY = S.X_CITY
AND P.X_STATE = S.X_STATE
(AND P.X_ZIP = S.X_ZIP) > 1);


Thank you

Kelly

Kelly wrote:
I'm trying to capture duplicates. However, only the address information will be duplicated.

For example:

There might be a Jody Smith and Tim Smith with different Membership_Ky with the same address. I need to find these documents.

Hi Kelly,

Then you can try this statement instead, which uses only a full table on your table scan:

select x_first_name
     , x_last_name
     , x_middle_name
     , x_membership_id
     , x_associate_id
     , x_member_ky
     , x_member_exp_date
     , x_join_club_date
     , x_membership_ky
     , x_address1
     , x_address2
     , x_city
     , x_state
     , x_zip
     , x_delivery_route
  from ( select x_first_name
              , x_last_name
              , x_middle_name
              , x_membership_id
              , x_associate_id
              , x_member_ky
              , x_member_exp_date
              , x_join_club_date
              , x_membership_ky
              , x_address1
              , x_address2
              , x_city
              , x_state
              , x_zip
              , x_delivery_route
              , count(*) over (partition by x_address1, x_address2, x_city, x_state, x_zip) cnt
           from canceled_customers
       )
 where cnt > 1

Note: not tested.

Kind regards
Rob.

Tags: Database

Similar Questions

  • Executions of dynamic query taking a long time

    Dear all,

    During the race the query below, it takes a long time to execute.

    [code]

    DECLARE

    statement varchar2 (1000);

    BEGIN

    FOR c1 IN (SELECT tenant_id FROM tenant WHERE tenant_id! = 0)

    LOOP

    FOR c2 IN (SELECT alignment_id FROM customer_alignment WHERE affiliation_id IS NULL AND tenant_id = c1.tenant_id)

    LOOP

    FOR c3 IN (SELECT vw.affiliation_id, vw.customer_id, vw.alignment_id, ca.customer_alignment_id

    OF ca_primary_address_vw vw, ca customer_alignment, WHERE ca.affiliation_id IS NULL

    AND ca.alignment_id = c2.alignment_id

    AND ca.customer_id = vw.customer_id

    AND ca.alignment_id = vw.alignment_id

    )

    LOOP

    Statement: = "UPDATE customer_alignment SET affiliation_id ='|" C3.affiliation_id | |' where customer_alignment_id =' | C3.customer_alignment_id;

    execute immediate (statement);

    END LOOP;

    END LOOP;

    END LOOP;

    END;

    [/ code]

    Can you please help me on this issue.

    I use the version of Oracle 11 g.

    Thanks a lot for your help.

    Miriam.

    Never perform a treatment by data line. SET the computer base. Direct use of the joints and cut single SQL. Your condition can be obtained by using the merge statement.

    merge into customer_alignment c
    using (
            select vw.affiliation_id
                 , ca.customer_alignment_id
              from customer_alignment c
              join tenant t
                on t.tenent_id       = c.tenent_id
               and t.tenent_id       != 0
               and c.affiliation_id is null
              join customer_alignment ca
                on ca.alignment_id  = c.alignment_id
               and ca.affiliation_id is null
              join ca_primary_address_vw vw
                on ca.customer_id   = vw.customer_id
               and ca.alignment_id  = vw.alignment_id
          ) t
       on (
             c.customer_alignment_id = t.customer_alignment_id
          )
     when matched then
     update
        set c.affiliation_id = t.affiliation_id;
    
  • Select the query takes a long time to run the second time

    Hi all

    I have Oracle 11 GR 1 material in windows server 2008 R2.
    I have a few tables with 10 million documents. When I run the select query to the tables of first time, it gives me a result in 15 seconds, but if I run the script even twice in the same session, I get the result in 15 minutes to complete...

    Why it's happening? What can be the solution for this?

    Thank you and best regards,
    Vikash jain (DBA Junior)

    What I know is that this feedback from cardinality generates more problems than improving the performance is, in fact, its main objective. But first look at which is was written in the link I posted above

    "Return of cardinality was introduced in the Oracle 11 g database 2. The purpose of this function is to automatically improve plans for queries that are executed repeatedly, _For that the optimizer does not estimate the cardinalities in the properly_ plan"

    If the cardinality feedback kiks in your case it is certainly because you do not have an exact statistics. Get the command the explain plans that I have shown you with the E-lines and A-lines (lines estimates and actual lines) and see where things are poorly estimated.

    If you want to disable the cardinality feedback then add the indicator according to your request

    /*+ opt_param('_optimizer_use_feedback','false') */
    

    Best regards

    Mohamed Houri
    www.hourim.WordPress.com

    Published by: Mohamed Houri on November 22, 2012 02:11
    Published by: I was looking for the exact indication of how do I deactivate the cardinality feedback and I foud in an ot the Dominic post in otn :-)

    Published by: Mohamed Houri on November 22, 2012 02:15

  • Query taking a long time to 12 c

    Dear all,

    We have a query that returns no output in 12 c. but same query gives output with in 2 seconds in the Database 11 g.

    Select a.id_place as id_place1, b.id_place as id_place2, minors (a.id_place) as minors1, minors (b.id_place) as ss_city_place_temp1 minors2 an inner join b on b.id_place_name ss_city_place_temp1 = a.id_place_name and b.id_place! = a.id_place and b.fl_active = a.fl_active and b.id_low_nbr = a.id_low_nbr and b.id_high_nbr = a.id_high_nbr and b.id_useing_area = a.id_useing_area and b.cd_side = a.cd_side and b.id_sub_ City = a.id_sub_city where a.id_city = 84 and a.fl_active = 'Y' order of a.id_place_name, a.cd_side, a.id_low_nbr, a.id_place;

    If I remove the order by cluase, its giving out in 12 c.

    I collected stats for the table. but no use.

    compared to 11 g, 12 c has more SGA.

    Please help me find the problem.

    Thank you and best regards,

    REDA

    problem solved,

    I think that his bug in 12 c,.

    After you change the settingoptimizer_features_enable='11.2.0.3' , its working fine.

    Thank you

    REDA

  • V10.11.3 OSX El Capitan taking a long time to open

    Why after update to OSX El Capitan v10.11.3 its taking a long time to open?

    Do you mean that it takes a lot of time for your computer to boot?  There could be several reasons for this.  Start by going to http://www.etresoft.com/etrecheck , download and run EtreCheck, copy paste here the status report.  It goes we will see what is currently on your system, and if there is something on this issue causing the extreme slowness of start-up, we see and advise you on what to do next.

  • Query takes a long time

    Hi Experts

    I'm using Oracle 11 g, I use under delete query to remove records of staging table.

    under query takes a long time (ranging from 1 hour, even there is no record to delete.

    I created payment_id indexes also did not help.

    delete from siebelwb.stg_p where payment_id not in (select * from siebel.s_src_payment)

    I know NOT of IN is degreding performace, is there another way to write above request so that we can remove them in NOT IN use.

    Try to use NOT EXISTS clause...

    Also you inner query must match the payment_id with query parent then here's the example query...

    removal of siebelwb.stg_p where THERE is NO payment_id (select 1 from siebel.s_src_payment where s_src_payment.payment_id = stg_p.payment_id)

  • I have tried, using the, trial version, creative, cloud, I, signed, until and started, the, download, download, is taking a long time, so, I, decided to cancel, she and buy, year, plan, pay, mont hly., I, started, download, creative, cloud, once again, bu

    I, tried, using the, trial version, creative, cloud, I, signed, until and started, the, download, download, is taking a long time, so, I, decided to cancel, she and buy, year, plan, pay, mont hly., I, started, download, creative, cloud, once again, but, downloading, was interrupted, by, ma, firefighters dau, by inserting, key usb, peripheral, in , the, USB port. , Could, not, I believe, downloading, I, signed, in, adobe, and now, tells me, that I, a, 30, day, trial, My, account, shows, that I have, I, p helps, my, first of all, every month, slice, but, I can only use a, trial, version, who, says, goes, e arentheses, 30, days., which can, I, do, for, get, the full, each year, the intention, version?

    Jacobm51486856 please see in Sign, activation or connection errors. CS5.5 and later for more information on how to resolve the error of connection that prevents your membership being authorized.

  • Taking a long time to power laptop

    Hi all

    My laptop (HP ENVY 17 - j005tx Notebook) when to stop only takes a few seconds, but it can take up to 5 minutes to be able to...

    At first I thought some service or program took a long time to stop, I installed Windows 8.1 SDK Performance Toolkit to try to identify a culprit. run the command "shutdown - traceFlags BASE + DIAG + LATENCY - noPrepReboot xbootmgr-trace" and the generated trace succeffully.

    I noticed that the notbook was restarted in a matter of seconds...

    Anyway, I proceeded to analyze the trace file using the wpa.exe anf program cannot find any program or service taking much time to stop!

    SO, I now understand the operating system Windows stops well even if the laptop is very long take-off power.

    Someone at - it suggestions?  I have installed NVIDIA driver 337.88 and found another thread here where they suspected this version of the driver has not been tested by HP and after they have applied it their judgment of the laptop slower than usual--is this somehting, perhaps to look at...

    I am currently downoading sp63414.exe NVIDIA driver for my laptop - should I uninstall my current driver and applies HP?

    Jim

    Laptop HP ENVY 17-j005tx, HP ENVY 27 - k001a, HP ProLiant MicroServer Gen8 G2020T, HP MediaSmart EX495 Server tilt, HP MediaVault 2020, HP ENVY 120 AiO Printer

    Thank you visruth...

    What I've tried is run "msconfig" and boot into "safe mode", restarted, then stop, stop was back to normal again.

    Then revived "msconfig" disabled all Microsoft Services, judgment and yet all fed off the coast as usual (soon after).

    Then restarted and re-enabled all services using "msconfig".  Disabled the following services, choose these particular that I'm not sure why they should be executed and some do not know what they are...

    rebooted and then stop and everything stop and power off was normal...

    It seems that one of these services is at the origin of the power off to take a few minutes...

    I suspect the bluetooth services, GSService, or IconMan_R, or even the genius of Netgear...

    Funny enough I did uninstall netgear genius a few weeks ago and see for some unknown reason, that the Service is still there? Hmm...

    Jim

  • MacBook Pro (13-inch, late 2011) taking a long time to start

    Hey everybody,

    I have a Macbook Pro (13 inch, late 2011), which takes a long time so that it starts about 1 min. This should automatically start since I have an SSD. Right? Specs are below:

    2.4 Ghz Intel Core i5 processor

    8GB memory

    Boot disk (my hard drive name)

    Intel HD Graphics 3000 512 MB graphics

    500GB Solid State hard drive

    I reboot mac, remove all items from the startup items, reset the SMC. What else is there to do?

    You have installed TRIM?

    Ciao.

  • Recycle Bin taking a long time to display confirm delete

    Then, when I right click > Recycle Bin empty, I could 5 to 15 seconds for the confirmation dialog to appear before allowing me to delete what was there, even if it is a single file.

    If I open the trash, it can also take some time to load.

    It seems windows knows how many files, the discrepancy between the loading of confirmation is reduced to normal.

    I have the latest Windows.

    RESOLVED:

    It turns out my hunch was right, I did a few tests every few hours.
    Whenever I had my on and not running outside, he crawls.
    Whenever I had my cut outside or not unplugged, no lag.

    I guess that's just something with the way windows checks the files to delete because he wanted to check if my outside was marked for deletion, even if there are no files. It would be nice if Microsoft should fix this but it's not exactly high priority.

    I wouldn't have spotted this problem without going through everything in the response but thanks for your efforts!

    Have a good day.

    Hello

    Programs such as Norton, McAfee and others can monitor or affect the trash
    so to use the clean boot method to see if there is something in the appearance of starting the
    issue. Use the rest of the troubleshooter if necessary.

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

    References to Vista also apply to Windows 7.

    What antivirus/antispyware/security products do you have on the machine? Be one you have NEVER
    on this machine, including those you have uninstalled (they leave leftovers behind which can cause
    strange problems).

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

    Follow these steps:

    Try these to erase corruption and missing/damaged file system repair or replacement.

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to fix the system files of Windows 7 with the System File Checker
    http://www.SevenForums.com/tutorials/1538-SFC-SCANNOW-Command-System-File-Checker.html

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Also run CheckDisk, so we cannot exclude as much as possible of the corruption.

    How to run check disk in Windows 7
    http://www.SevenForums.com/tutorials/433-disk-check.html

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

    After the foregoing:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or
    Windows 7

    http://support.Microsoft.com/kb/929135

    Use advanced tools to solve performance problems in Windows 7
    http://www.howtogeek.com/HOWTO/6152/use-advanced-tools-to-troubleshoot-performance-problems-in-Windows-7/

    Problems with the overall speed of the system and performance
    http://support.Microsoft.com/default.aspx/GP/slow_windows_performance?p=1

    How to troubleshoot performance issues in Windows Vista
    http://support.Microsoft.com/kb/950685

    Optimize the performance of Microsoft Windows Vista
    http://support.Microsoft.com/kb/959062
    To see everything that is in charge of startup - wait a few minutes with nothing to do - then right-click
    Taskbar - the Task Manager process - take a look at stored by - Services - this is a quick way
    reference (if you have a small box at the bottom left - show for all users, then check that).

    How to change, add or remove startup programs in Windows 7
    http://www.SevenForums.com/tutorials/1401-startup-programs-change.html

    A quick check to see that load method 2 is - using MSCONFIG then put a list of
    those here.
    --------------------------------------------------------------------

    Tools that should help you:

    Process Explorer - free - find out which files, key of registry and other objects processes have opened.
    What DLLs they have loaded and more. This exceptionally effective utility will show you even who has
    each process.
    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896653.aspx

    Autoruns - free - see what programs are configured to start automatically when you start your system
    and you log in. Autoruns also shows you the full list of registry and file locations where applications can
    Configure auto-start settings.
    http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspx
    Process Monitor - Free - monitor the system files, registry, process, thread and DLL real-time activity.
    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896645.aspx

    There are many excellent free tools from Sysinternals
    http://TechNet.Microsoft.com/en-us/Sysinternals/default.aspx

    -Free - WhatsInStartUP this utility displays the list of all applications that are loaded automatically
    When Windows starts. For each request, the following information is displayed: Type of startup (registry/Startup folder), Command - Line String, the product name, Version of the file, the name of the company;
    Location in the registry or the file system and more. It allows you to easily disable or remove unwanted
    a program that runs in your Windows startup.
    http://www.NirSoft.NET/utils/what_run_in_startup.html

    There are many excellent free tools to NirSoft
    http://www.NirSoft.NET/utils/index.html

    Window Watcher - free - do you know what is running on your computer? Maybe not. The window
    Watcher says it all, reporting of any window created by running programs, if the window
    is visible or not.
    http://www.KarenWare.com/PowerTools/ptwinwatch.asp

    Many excellent free tools and an excellent newsletter at Karenware
    http://www.KarenWare.com/

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

    Think about it an absolute must - manually update your drivers.

    Vista and Windows 7 updated drivers love then here's how update the most important.

    This is my generic how updates of appropriate driver:

    This utility, it is easy see which versions are loaded:

    -Free - DriverView utility displays the list of all device drivers currently loaded on your system.
    For each driver in the list, additional useful information is displayed: load address of the driver,
    Description, version, product name, company that created the driver and more.
    http://www.NirSoft.NET/utils/DriverView.html

    For drivers, visit manufacturer of emergency system and of the manufacturer of the device that are the most common.
    Control Panel - device - Graphics Manager - note the brand and complete model
    your video card - double - tab of the driver - write version information. Now, click on update
    Driver (this can do nothing as MS is far behind the certification of drivers) - then right-click.
    Uninstall - REBOOT it will refresh the driver stack.

    Repeat this for network - card (NIC), Wifi network, sound, mouse, and keyboard if 3rd party
    with their own software and drivers and all other main drivers that you have.

    Now in the system manufacturer (Dell, HP, Toshiba as examples) site (in a restaurant), peripheral
    Site of the manufacturer (Realtek, Intel, Nvidia, ATI, for example) and get their latest versions. (Look for
    BIOS, Chipset and software updates on the site of the manufacturer of the system here.)

    Download - SAVE - go to where you put them - right click - RUN AD ADMIN - REBOOT after
    each installation.

    Always check in the Device Manager - drivers tab to be sure the version you actually install
    presents itself. This is because some restore drivers before the most recent is installed (sound card drivers
    in particular that) so to install a driver - reboot - check that it is installed and repeat as
    necessary.

    Repeat to the manufacturers - BTW in the DO NOT RUN THEIR SCANNER device - check
    manually by model.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Installation and update of drivers under Windows 7 (updated drivers manually using the methods above
    It is preferable to ensure that the latest drivers from the manufacturer of system and device manufacturers are located)
    http://www.SevenForums.com/tutorials/43216-installing-updating-drivers-7-a.html

    If you update the drivers manually, then it's a good idea to disable the facilities of driver under Windows
    Updates, that leaves about Windows updates but it will not install the drivers that will be generally
    older and cause problems. If updates offers a new driver and then HIDE it (right click on it), then
    get new manually if you wish.

    How to disable automatic driver Installation in Windows Vista - drivers
    http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
    http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx

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

    Refer to these discussions because many more excellent advice however don't forget to check your antivirus
    programs, the main drivers and BIOS update and also solve the problems with the cleanboot method
    first.

    Problems with the overall speed of the system and performance
    http://support.Microsoft.com/GP/slow_windows_performance/en-us

    Performance and Maintenance Tips
    http://social.answers.Microsoft.com/forums/en-us/w7performance/thread/19e5d6c3-BF07-49ac-a2fa-6718c988f125

    Explorer Windows stopped working
    http://social.answers.Microsoft.com/forums/en-us/w7performance/thread/6ab02526-5071-4DCC-895F-d90202bad8b3

    I hope this helps.

  • DELETE the query takes a long time

    Hi all guru.

    My Version of DB: 10.2.0
    OS: Windows Server 2003

    I run a delete on a table of paritioned command to remove all the lines in one of the parition. The command is:

    The table name is cat_in_data_052012

    delete CAT_IN_DATA_052012 WHERE name of FILE AS: SYS_B_O


    Table conatins million record.


    Thanks in advance

    >
    I run a delete on a table of paritioned command to remove all the lines in one of the parition. The command is:

    The table name is cat_in_data_052012

    delete CAT_IN_DATA_052012 WHERE name of FILE AS: SYS_B_O
    >
    Mention the name of partition specifically in the query to ensure that only one partition is affected.

    See the example (at the end) for the deletion of rows in a Partition in the SQL reference Guide
    http://docs.Oracle.com/CD/B12037_01/server.101/b10759/statements_8005.htm#i2126857

    Deleting Rows from a Partition: Example
    
    The following example removes rows from partition sales_q1_1998 of the sh.sales table:
    
    DELETE FROM sales PARTITION (sales_q1_1998)
       WHERE amount_sold > 10000;
    
  • (createvw.dms) stuck for a long time while running data mover

    Hi all

    First of all, thank you to all our friends in what have been great in answering all of our questions and help us do our work effectively.

    My question:

    1. we had installed Peoplesoft HRMS successfully for purposes of demonstration, which works very well.
    2. we followed the same sequence of steps to install Peoplesoft FSCM 9.1 to another Windows 2003 server. We had followed the steps as stated in
    [http://milburytech.blogspot.in/]
    3. we have been checking the logs at regular intervals for errors and comparing with the log files, the HRMS Setup logs, but did not find significant errors.
    4 data mover has worked for more than 16 hours now and has been blocked to "view (s) remaining: 119 creation held AUC_SCR_CHT_VW.

    My query:

    1 can we kill the data mover and run it once more to continue on the display component to create?
    2. in case if she-error, can we continue without the view 119 remaining being created?
    3. it causes problems (in particular, access associated (as one of my other nationalities, said that they had faced the same question last month and they spontaneous able to connect to the application (as SYSADM) Designer after that they tried to ignore the creation of panoramas).)





    Kind regards
    Vikram

    Hello

    A stucks Data Mover on the aspect of creating strange view, but it could easily be killed without any problem. Just re - open DMS mode bootstrap and the missing steps:

    REPLACE_VIEW *;
    CREATE_TEMP_TABLE *;
    

    Nicolas.

    PS: SYSADM is a database user and has no right to connect to AppDesigner.

    Published by: Gasparotto N 2 February 2012 09:50

  • OWB mapping takes a long time to run

    Hello

    I'm developing an application of storage/storage.
    I created a few dimensions and cubes.
    But the problem comes when I try to load the cube by running the mapping.
    The data is small (10K lines) and the dimension loading through the mapping runs very fast (1 minute maximum).
    But when I try to load the cube by running the cube mapping, it takes hours (and it shows 'Running' State forever)

    The possible reasons for this behavior?

    My source is target of 10g 11g.

    Thank you

    Check the plan, noticed in the past there was no unique key on the operational column of the lowest level of the dimension table, in order to make the full sweep of the table on the research dimension table when in fact loading. If so, stick a UK on level business key column further down.

    See you soon
    David

  • script takes a long time to run

    Hi friends,



    We have a record of leave in the following way:



    name date leaves

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

    ABC 1 October 08 1

    ABC 2 October 08 1

    ABC 3 October 08 1

    ABC October 4 08 1

    ABC 5 October 08 1

    ABC 10 October 08 1

    ABC 18 October 08 1

    ABC, 19 October 08 1

    ABC 20 October 08 1

    ABC October 25 08 1

    ABC 26 October 08 1

    ABC 27 October 08 1

    ABC October 28 08 1



    and we need an output in the following way:



    output

    -------



    Name FromDate date leaves

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

    ABC 1 October 08 5 October 08 5

    ABC October 10 08 10 October 08 1

    ABC 18 October 08 20 October 08 3

    ABC 25 October 08 28 October 08 4





    The previously mentioned code logic is the following:

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

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

    procedure KPM_AB_LWP_PROC (p_err_buf OUT VARCHAR2, p_ret_code OUT NUMBER) is

    number of diff;

    date of prev_date;

    date of p_prev_date;

    date first_date;

    date of last_date;

    date DT;

    total_leaves number: = 0;

    ECODE varchar2 (20);

    Ename varchar2 (240);



    cursor ab_lwp_cur (the process_from_date date, process_to_date date, e_code varchar2) is

    Select

    AB. EMPCODE,

    AB. RECORD_DATE,

    AB. FIRST_HALF,

    AB. SECOND_HALF,

    (em.last_name |) ', ' || EM. TITLE | ' '|| EM. FIRST_NAME. EM. EMP_NAME MIDDLE_NAME)

    Of

    kpm_hr_absent_record ab, kpm_hr_emp_mst em

    where

    AB. EMPCODE = em. EMPCODE

    (AB. FIRST_HALF in ("AB", "LWP") or ab. SECOND_HALF ("AB", "LWP"))

    and ab. EMPCODE as e_code

    and ab.record_date between process_from_date and process_to_date;



    cursor active_emp is

    Select empcode

    of kpm_hr_emp_mst

    When status = 'Active'.

    order by empcode;

    Start

    for emp loop active_emp

    Start

    Select min (ab. RECORD_DATE), max (ab. RECORD_DATE)

    in prev_date, last_date

    kpm_hr_absent_record AB

    where (ab. FIRST_HALF in ("AB", "LWP") or ab. SECOND_HALF ("AB", "LWP"))

    and ab. EMPCODE as emp.empcode;

    exception

    while others then

    prev_date: = null;

    last_date: = null;

    end;



    DT: = prev_date;



    FND_FILE. PUT_LINE (FND_FILE. OUT, 'salaried worker | Chr (9) | Chr (9) | "Name" | Chr (9) | Chr (9) | 'Count '. Chr (9) | Chr (9) | "To this day". Chr (9) | Chr (9) | 'Sheets' total);

    FND_FILE. PUT_LINE (FND_FILE. OUT,'-'. Chr (9) | Chr (9) | '-----' || Chr (9) | Chr (9) | '----------' || Chr (9) | Chr (9) | '---------' || Chr (9) | Chr (9) | '-------------');



    While dt & lt; = last_date loop

    first_date: = dt;

    total_leaves: = 0;



    for m loop (prev_date, last_date, emp.empcode) ab_lwp_cur

    ECODE: = m.empcode;

    Ename: = m.emp_name;

    diff: = m.record_date - prev_date;



    If diff = 0 then

    If m.first_half ("AB", "LWP") then

    total_leaves: = total_leaves + 0.5;

    end if;

    If m.second_half ("AB", "LWP") then

    total_leaves: = total_leaves + 0.5;

    end if;

    prev_date: = prev_date + 1;

    on the other

    prev_date: = m.record_date;

    GoTo print_leave;

    end if;



    p_prev_date: = prev_date-1;

    end loop;



    & lt; & lt; print_leave & gt; & gt;



    If total_leaves & gt; 0 then

    FND_FILE. PUT_LINE (FND_FILE. OUTPUT, ecode | Chr (9) | Chr (9) | Ename | Chr (9) | Chr (9) | first_date | Chr (9) | Chr (9) | p_prev_date | Chr (9) | Chr (9) | total_leaves);

    end if;



    DT: = prev_date;

    end loop;

    end loop;

    exception

    while others then

    FND_FILE. PUT_LINE (FND_FILE. JOURNAL,' error: '. SQLERRM);

    end KPM_AB_LWP_PROC;

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

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





    The problem is that this code takes about 24 hours to run, which is not accepted.

    Please suggest another technique to apply the same logic.



    For your reference, the KPM_HR_ABSENT_RECORD table has about 3,75,000 files inside.

    Also, we have created a few clues about certain column as recommended by explaining the plans.



    Thanks in advance

    Ankur
    with t as (select 'ABC' as nm, to_date('01-oct-08','dd-mon-yy') as dt, 1 as leaves from dual union all
                   select 'ABC',to_date('02-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('03-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('04-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('05-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('10-oct-08','dd-mon-yy'), 1 from dual union all
                  select 'ABC',to_date('18-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('19-oct-08','dd-mon-yy'), 1 from dual union all
                   select 'ABC',to_date('20-oct-08','dd-mon-yy'), 1 from dual union all
                  select 'ABC',to_date('25-oct-08','dd-mon-yy'), 1 from dual union all
                  select 'ABC',to_date('26-oct-08','dd-mon-yy'), 1 from dual union all
                  select 'ABC',to_date('27-oct-08','dd-mon-yy'), 1 from dual union all
                  select 'ABC',to_date('28-oct-08','dd-mon-yy'), 1 from dual)
       -- end of sample data
    select nm, min(dt), max(dt), sum(leaves)
    from
    (
       select nm, dt, max(group_id) over(partition by nm order by dt) group_id
                , leaves
       from
       (
          select nm, dt, case when trunc(dt) - 1 != lag(trunc(dt),1,trunc(dt))
                                                                     over(partition by nm order by dt)
                               then rownum
                               end group_id
                 , leaves
          from t
       )
    )
    group by nm, group_id
    order by 1,2;
    

    I hope this helps.

    @Blushadow, thanks a lot for the test data.

    Concerning

    REDA

    PS: For more information visit this link
    http://www.Oracle.com/technology/oramag/Oracle/04-Mar/o24asktom.html

    and search this page for "Analytical to the rescue (again)".

    Published by: R.Subramanian on October 22, 2008 04:52
    Account function has changed function Sum

  • WANT to m6: Windows Update taking a long time

    My laptop recently had an update waiting for a 'new feature windows 10', I decided to update by clicking on update and close. Once that the screen says of things such as the update of preparation and installation of update.
    Then a black screen pops up and had a white buffering the symbol on the bottom, similar to the start, but without the hp logo screen. Since the update, my laptop has slept on this screen for about 30 hours now, with the buffering continuous symbol.
    Is this normal? Is there a possible way to speed up the process?

    Hi@Jaysonic,

    Welcome HP forums . The best place for all kinds of solutions, tips and settings for your questions/problems.

    For the best experience on HP forum, see our Guide to HP Forums to learn more.

    Stuck Windows Update. Is this fair?

    I will definitely help you.

    Try to restart the PC once and see if that starts the process of update quickly.

    Let me know to learn more.

    Resolv_S

    Happy to help you. I work for HP

    Please click "Accept as Solution" if you feel my post solved your problem, it will help others find the solution.
    Click on ' Bravo Thumbs Up ' to say 'Thank you' to help!

Maybe you are looking for