Sql query to update record?

hi1
i have 1000 rows in my table that are not unique. i have added a new column named sno.initially that contains null values. Now i want to update the table with sno contains serial no. from 1 to 1000 in a single SQL query
please help
Thanks
Harinder

hi1
i have 1000 rows in my table that are not unique. i
have added a new column named sno.initially that
contains null values. Now i want to update the table
with sno contains serial no. from 1 to 1000 in a
single SQL query
please help
Thanks
HarinderIt will work..
Update <table_name> set <column_name> = ROWNUM
whether the records are duplicate or not...

Similar Messages

  • SQL query to fetch records  from  26 onwards

    Want to know SQL query to fetch records from 26 onwards.

    See the fifth entry on the FAQ page:
    Re: How to attach a java bean in forms6i

  • Sql Query to store record like warehoue wise items

    Hi Experts
    I want to ask you a sql query for inserting records from two table OITM and OWHS in a user definded table like OITW.
    I have a table BINMASTER in which bin code are stored. Now I want to create a table Like OWHS where BIN Wise Item records to be stored Let See
    Item01 Bin 01
    Item02 Bin 01
    Item03 Bin 01
    Item01 Bin 02
    Item02 Bin 02
    Item03 Bin 02
    Plz give your suggestions
    Regards
    Gorge

    hi János Nagy 
    Thank for reply
    your statement is fine with no where condition. But I want to insert in a UDT in which Code, Name are two field which should be unique for every record. I use following statement
    Insert into (Code, name, Itemcode, ItemDescription, Bincode , Warehouse )
    select                                      ?,     ?, T1.Itemcode, T2.ItemDescription, T2.Bincode , T3.WhsCode From Oitm T1, T2, Owhs T3
    Here what I insert in Code and Name fields
    Regards
    Gorge

  • Sql query to retrieve records in parent sibling relationship in a table

    I need help to write this Sql query on a table where it has the primary_id, parent_id, and sibling_id. A new row can be created with or without the parent_id and sibling_id. However most of the new rows are created from an existing row and the primary_id
    of the existing row is inserted to the parent_id of the new row. This can go on for many many rows such as (B's parent_id has A primary_id, A's sibling_id has B primary_id), (C's parent_id has B primary_id, B's sibling_id has C primary_id), (D's
    parent_id has C primary_id, C's sibling_id has D primary_id), What I want is when user pass on a primary_id on a row, the query will give me back all the related parent_id or sibling_id records. For example User pass the A's primary_id the query will
    give me back the Row B and Row C as a sibling rows or user pass the C's primary_id the query should give me back row B and Row A as parent rows. Thanks
    Kahlua

    Check http://social.technet.microsoft.com/wiki/contents/articles/21062.t-sql-hierarchical-table-sorting-with-a-parent-child-relation.aspx
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Sql query - Selecting last recorded values for each date in specified period

    Hello,
    Can someone please help me with my problem.
    I'm trying to get last recorded balance for each day for specific box (1 or 2) in specified period of days from ms access database using ADOTool.
    I'm trying to get that information with SQL query but so far unsuccessfully...  
    My table looks like this:
    Table name: TestTable
    Date Time Location Box Balance
    20.10.2014. 06:00:00 1 1 345
    20.10.2014. 12:00:00 1 1 7356
    20.10.2014. 18:45:00 1 1 5678
    20.10.2014. 23:54:00 1 1 9845
    20.10.2014. 06:00:02 1 2 35
    20.10.2014. 12:00:04 1 2 756
    20.10.2014. 18:45:06 1 2 578
    20.10.2014. 23:54:10 1 2 845
    21.10.2014. 06:00:00 1 1 34
    21.10.2014. 12:05:03 1 1 5789
    21.10.2014. 15:00:34 1 1 1237
    21.10.2014. 06:00:00 1 2 374
    21.10.2014. 12:05:03 1 2 54789
    21.10.2014. 15:00:34 1 2 13237
    22.10.2014. 06:00:00 1 1 8562
    22.10.2014. 10:00:00 1 1 1234
    22.10.2014. 17:03:45 1 1 3415
    22.10.2014. 22:00:00 1 1 6742
    22.10.2014. 06:00:05 1 2 562
    22.10.2014. 10:00:16 1 2 123
    22.10.2014. 17:03:50 1 2 415
    22.10.2014. 22:00:10 1 2 642
    23.10.2014. 06:00:00 1 1 9876
    23.10.2014. 09:13:00 1 1 223
    23.10.2014. 13:50:17 1 1 7768
    23.10.2014. 19:47:40 1 1 3456
    23.10.2014. 21:30:00 1 1 789
    23.10.2014. 23:57:12 1 1 25
    23.10.2014. 06:00:07 1 2 976
    23.10.2014. 09:13:45 1 2 223
    23.10.2014. 13:50:40 1 2 78
    23.10.2014. 19:47:55 1 2 346
    23.10.2014. 21:30:03 1 2 89
    23.10.2014. 23:57:18 1 2 25
    24.10.2014. 06:00:55 1 1 346
    24.10.2014. 12:30:22 1 1 8329
    24.10.2014. 23:50:19 1 1 2225
    24.10.2014. 06:01:00 1 2 3546
    24.10.2014. 12:30:26 1 2 89
    24.10.2014. 23:51:10 1 2 25
    Let's say the period is 21.10.2014. - 23.10.2014. and I want to get last recorded balance for box 1. for each day. The result should look like this:
    Date Time Location Box Balance
    21.10.2014. 15:00:34 1 1 1237
    22.10.2014. 22:00:00 1 1 6742
    23.10.2014. 23:57:12 1 1 25
    So far I've managed to write a query that gives me balance for ONLY ONE date (date with highest time in whole table), but I need balance for EVERY date in specific period.
    My incorrect code (didn't manage to implement "BETWEEN" for dates...):
    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    Tnx!
    Solved!
    Go to Solution.

    For loop
    following query keep day (here 24 in below query) Variable from ( 1 to 28-29/30/31 as per month)
    SELECT TOP 1 TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM Test Table.
    WHERE  Time=(SELECT MAX(Time) FROM TestTable WHERE Location=1 AND Box=1 )
    AND DATE = "2014-10-24";
    PBP (CLAD)
    Labview 6.1 - 2014
    KUDOS ARE WELCOMED.
    If your problem get solved then mark as solution.

  • Form on SQL query for updating.

    Hello again,
    Im trying to wirte a form to udapte the information in a table. I have a table with a PK which holds a persons name, and an activity assigned to them (and loads of other fields but they dont matter atm). I would like to have a form which has an SQL query running in one region and then the form underneath to be able to edit (reassign a person to a different activity) an item appearing in the query result. Ive got a form at the moment which is form on an sql query but its not updating when i fill out the form, is it something to do with the regions?
    http://img.photobucket.com/albums/v611/Funky_Monk/untitled.jpg
    So on the screenie, i have the bottom region for the query (no values in table hence the error (i think!))
    The call ID is FK to another table
    severity level and status will be usdated here
    description is self-explanitory
    analyst_id is the main field to be changed here, the call id will be assigned a new analyst via this form.
    action_id is actions carried out on this problem.
    Any help would be greatly appreciated.
    DM

    hi,
    Can you put this example on apex.oracle.com?
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • [Solved partially] Sql query for updates compliance

    Hello
    I'm trying (with no success) to translate the "Software+Updates+-+A+Compliance%2fCompliance+1+-+Overall+compliance" report into a sql query that must run for a specific
    Software update group and for a specific Collection ID.
    The expected result should be like the report it self, I mean 3 lines with Kpi (pourcentage).
    The main query in this report is : 
    select
    CollectionID=@CollID,
    Status=sn.StateName,
    cs.NumberOfComputers,
    PComputers=convert(float, isnull(cs.NumberOfComputers, 0)*100.00) / isnull(nullif(cs.NumTotal, 0), 1),
    AuthListID=@AuthListID
    from (select CI_ID, NumTotal, [0]=NumUnknown, [1]=NumPresent+NumNotApplicable, [2]=NumMissing
    from fn_rbac_UpdateSummaryPerCollection(@UserSIDs)
    where CI_ID=@CI_ID and CollectionID=@CollID
    ) cnt
    unpivot (NumberOfComputers for [Status] in ([0], [1], [2])) cs
    left join fn_rbac_StateNames(@UserSIDs) sn on sn.TopicType=300 and sn.StateID=cs.Status
    where cs.NumberOfComputers>0
    order by cs.NumberOfComputers desc
    I have no clue on how to replace or use fr_rbac view when run outside a report.
    Can you please help me ?
    Thanks

    Hi,
    Glad to hear that and thank you for your sharing.
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • SQL Query to update UDF

    Hi all
    Can anyone please assist me here , on my db i have
    three UDF's linked to one table.
    These UDF's are for routes - when you select the route code the query must update the route name and the driver name .
    This info is all in one UDT.
    Thanks

    Hello Bongani,
    SELECT
       T0.U_DriverName
    FROM
       .[@Routes] T0
    WHERE
       T0.Code=$[TABLE.FIELD]
    /code
    I assume you have the Routes UDT set like this:
    Code | Name | DriverName | ...
    Just change TABLE and FIELD with the name of the table and field you're importing the value to.
    Best Regards,
    Vítor

  • SQL Query for update

    hi experts
    I got two tables
    BOOK (DDC,TITLE,ISBN,AUTH_NAME)
    AUTHOR (ID,DDC,AUTH_NAME)
    AUTH_NAME column in BOOK's table contains NULL for all records.
    I want update table BOOK's column AUTH_NAME from AUTHOR's column in AUTHOR table where DDC numbers match. DDC is not unique in AUTHOR's table. I want to update BOOK table with the first matching AUTH_NAME. Rest should be ignored.
    Please write me the query for it.
    thanks

    Please write me the query for it.This fellow has no questions.
    Please, DO NOT ANNOY HIM with hints and tips, he just wants his answer. ; )
    I suspect it's homework, just another cheating student, earning his OCP.
    He is very anxious to get somebody to do his work, as he has spammed this same questtion on several other Oracle forums:
    http://dba.ipbhost.com/index.php?showtopic=10441
    http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=32264

  • SQL Query to update Item OnHand in SAP B1 2005

    hi all,
                  is it possible to write a Update query in sql to modify item OnHand ? is it possible to do that in SAP B1 for UDF?
         i want to create a UDF and the enter value in it should be deducted from the Item OnHand Stock. is there any query is possible to modify the item on hand.
    if it is possible then kindly send me the query.
    sandip

    hey sandip if u are updatin ur own fields then it is allowed. But if it a field in the sap tables then NO way.. U gotta use the DI API to update these fields.. I u want to reduce the stock the n use the Goods Issue DIAPI.. I tink its The INVGenEXit DiAPI.. Remember if u using the DiApI u Allowed to do only wat u can in the front end
    Regards
    Aris

  • SQL Query to update Item OnHand in SAP B1

    hi all,
                  is it possible to write a Update query in sql to modify item OnHand ? is it possible to do that in SAP B1 for UDF?
         i want to create a UDF and the enter value in it should be deducted from the Item OnHand Stock. is there any query is possible to modify the item on hand.
    if it is possible then kindly send me the query.
    sandip

    Hi Sandip,
    Modifying the OnHand quantity for an item directly through SQL is forbidden by SAP. Updating a UDF is also not recommended. The recommended method for updating a UDF is through the SDK.
    I'm not sure what you are trying to achieve. If you wish to change the stock quantity for an item then you need to add the most appropriate transaction, either through the UI or via the SDK (eg Goods Issue, Goods Receipt, AR Delivery etc).
    Kind Regards,
    Owen

  • Enhance a SQL query with update of millions of rows

    Hi ,
    I have this query developed to updated around 200 million of rows on my production , I did my best but please need your recommendations\concerns to make it more enhanced
    DECLARE @ORIGINAL_ID AS BIGINT
    SELECT FID001 INTO #Temp001_
    FROM INBA004 WHERE RS_DATE>='1999-01-01'
    AND RS_DATE<'2014-01-01' AND CLR_f1st='SSLM'
    and FID001 >=12345671
    WHILE (SELECT COUNT(*) FROM #Temp001_ ) <>0
    BEGIN
    SELECT TOP 1 @ORIGINAL_ID=FID001 FROM #Temp001_ ORDER BY FID001
    PRINT CAST (@ORIGINAL_ID AS VARCHAR(100))+' STARTED'
    SELECT DISTINCT FID001
    INTO #OUT_FID001
    FROM OUTTR009 WHERE TRANSACTION_ID IN (SELECT TRANSACTION_ID FROM
    INTR00100 WHERE FID001 = @ORIGINAL_ID)
    UPDATE A SET RCV_Date=B.TIME_STAMP
    FROM OUTTR009 A INNER JOIN INTR00100 B
    ON A.TRANSACTION_ID=B.TRANSACTION_ID
    WHERE A.FID001 IN (SELECT FID001 FROM #OUT_FID001)
    AND B.FID001=@ORIGINAL_ID
    UPDATE A SET Sending_Date=B.TIME_STAMP
    FROM INTR00100 A INNER JOIN OUTTR009 B
    ON A.TRANSACTION_ID=B.TRANSACTION_ID
    WHERE A.FID001=@ORIGINAL_ID
    AND B.FID001 IN (SELECT FID001 FROM #OUT_FID001)
    DELETE FROM #Temp001_ WHERE FID001=@ORIGINAL_ID
    DROP TABLE #OUT_FID001
    PRINT CAST (@ORIGINAL_ID AS VARCHAR(100))+' FINISHED'
    END

    DECLARE @x INT
    SET @x = 1
    WHILE @x < 44,000,000  -- Set appropriately
    BEGIN
        UPDATE Table SET a = c+d where ID BETWEEN @x AND @x + 10000
        SET @x = @x + 10000
    END
    Make sure that ID column has a CI on.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • During SQL query inserting a record - will it appear on the query result

    Hi,
    Oracle 10g SELECT-query executes ca 10 seconds and contains Joins over multiple tables in on database conenction.
    On execution 3rd second a new record is inserted in another database connection and commited to the database, the 3rd query satisgy the SELECT-Query fileters.
    Wil lthe inserted record on 3rd second appear on the query results?
    Thx.

    CharlesRoos wrote:
    Hi,
    Oracle 10g SELECT-query executes ca 10 seconds and contains Joins over multiple tables in on database conenction.
    On execution 3rd second a new record is inserted in another database connection and commited to the database, the 3rd query satisgy the SELECT-Query fileters.
    Wil lthe inserted record on 3rd second appear on the query results?
    Thx.In general Keith is right and a select will not see changes done and committed in a different session, that happend during the select. This is called READ CONSISTENCY. THis means a select will see the data from the exact time when it was called.
    However with database links in place read consistency can not be fully garanteed.
    See this explaination and solution from the 10g docs : http://docs.oracle.com/cd/B19306_01/server.102/b14231/ds_txnman.htm#i1008473

  • SQL Query to fetch records from tables which have 75+ million records

    Hi,
    I have the explain plan for a sql stmt.Require your suggestions to improve this.
    PLAN_TABLE_OUTPUT
    | Id  | Operation                            | Name                         | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                     |                              |   340 |   175K| 19075 |
    |   1 |  TEMP TABLE TRANSFORMATION           |                              |       |       |       |
    |   2 |   LOAD AS SELECT                     |                              |       |       |       |
    |   3 |    SORT GROUP BY                     |                              |    32M|  1183M|   799K|
    |   4 |     TABLE ACCESS FULL                | CLM_DETAIL_PRESTG            |   135M|  4911M|   464K|
    |   5 |   LOAD AS SELECT                     |                              |       |       |       |
    |   6 |    TABLE ACCESS FULL                 | CLM_HEADER_PRESTG            |     1 |   274 |   246K|
    PLAN_TABLE_OUTPUT
    |   7 |   LOAD AS SELECT                     |                              |       |       |       |
    |   8 |    SORT UNIQUE                       |                              |   744K|    85M|  8100 |
    |   9 |     TABLE ACCESS FULL                | DAILY_PROV_PRESTG            |   744K|    85M|  1007 |
    |  10 |   UNION-ALL                          |                              |       |       |       |
    |  11 |    SORT UNIQUE                       |                              |   177 | 97350 |  9539 |
    |  12 |     HASH JOIN                        |                              |   177 | 97350 |  9538 |
    |  13 |      HASH JOIN OUTER                 |                              |     3 |  1518 |  9533 |
    |  14 |       HASH JOIN                      |                              |     1 |   391 |  8966 |
    |  15 |        TABLE ACCESS BY INDEX ROWID   | CLM_DETAIL_PRESTG            |     1 |    27 |     3 |
    |  16 |         NESTED LOOPS                 |                              |     1 |   361 |    10 |
    |  17 |          NESTED LOOPS OUTER          |                              |     1 |   334 |     7 |
    PLAN_TABLE_OUTPUT
    |  18 |           NESTED LOOPS OUTER         |                              |     1 |   291 |     4 |
    |  19 |            VIEW                      |                              |     1 |   259 |     2 |
    |  20 |             TABLE ACCESS FULL        | SYS_TEMP_0FD9D66C9_DA2D01AD  |     1 |   269 |     2 |
    |  21 |            INDEX RANGE SCAN          | CLM_PAYMNT_CLMEXT_PRESTG_IDX |     1 |    32 |     2 |
    |  22 |           TABLE ACCESS BY INDEX ROWID| CLM_PAYMNT_CHKEXT_PRESTG     |     1 |    43 |     3 |
    |  23 |            INDEX RANGE SCAN          | CLM_PAYMNT_CHKEXT_PRESTG_IDX |     1 |       |     2 |
    |  24 |          INDEX RANGE SCAN            | CLM_DETAIL_PRESTG_IDX        |     6 |       |     2 |
    |  25 |        VIEW                          |                              |    32M|   934M|  8235 |
    |  26 |         TABLE ACCESS FULL            | SYS_TEMP_0FD9D66C8_DA2D01AD  |    32M|   934M|  8235 |
    |  27 |       VIEW                           |                              |   744K|    81M|   550 |
    |  28 |        TABLE ACCESS FULL             | SYS_TEMP_0FD9D66CA_DA2D01AD  |   744K|    81M|   550 |
    PLAN_TABLE_OUTPUT
    |  29 |      TABLE ACCESS FULL               | CCP_MBRSHP_XREF              |  5288 |   227K|     5 |
    |  30 |    SORT UNIQUE                       |                              |   163 | 82804 |  9536 |
    |  31 |     HASH JOIN                        |                              |   163 | 82804 |  9535 |
    |  32 |      HASH JOIN OUTER                 |                              |     3 |  1437 |  9530 |
    |  33 |       HASH JOIN                      |                              |     1 |   364 |  8963 |
    |  34 |        NESTED LOOPS OUTER            |                              |     1 |   334 |     7 |
    |  35 |         NESTED LOOPS OUTER           |                              |     1 |   291 |     4 |
    |  36 |          VIEW                        |                              |     1 |   259 |     2 |
    |  37 |           TABLE ACCESS FULL          | SYS_TEMP_0FD9D66C9_DA2D01AD  |     1 |   269 |     2 |
    |  38 |          INDEX RANGE SCAN            | CLM_PAYMNT_CLMEXT_PRESTG_IDX |     1 |    32 |     2 |
    |  39 |         TABLE ACCESS BY INDEX ROWID  | CLM_PAYMNT_CHKEXT_PRESTG     |     1 |    43 |     3 |
    PLAN_TABLE_OUTPUT
    |  40 |          INDEX RANGE SCAN            | CLM_PAYMNT_CHKEXT_PRESTG_IDX |     1 |       |     2 |
    |  41 |        VIEW                          |                              |    32M|   934M|  8235 |
    |  42 |         TABLE ACCESS FULL            | SYS_TEMP_0FD9D66C8_DA2D01AD  |    32M|   934M|  8235 |
    |  43 |       VIEW                           |                              |   744K|    81M|   550 |
    |  44 |        TABLE ACCESS FULL             | SYS_TEMP_0FD9D66CA_DA2D01AD  |   744K|    81M|   550 |
    |  45 |      TABLE ACCESS FULL               | CCP_MBRSHP_XREF              |  5288 |   149K|     5 |
    The CLM_DETAIL_PRESTG table has 100 million records and the CLM_HEADER_PRESTG table has 75 million records.
    Any gussestions on how to getch huge records from tables of this size will help.
    Regards,
    Narayan

    WITH CLAIM_DTL
         AS (  SELECT
                      ICN_NUM,
    MIN (FIRST_SRVC_DT) AS FIRST_SRVC_DT,
    MAX (LAST_SRVC_DT) AS LAST_SRVC_DT,
    MIN (PLC_OF_SRVC_CD) AS PLC_OF_SRVC_CD
    FROM CCP_STG.CLM_DETAIL_PRESTG  CD WHERE ACT_CD <>'D'
    GROUP BY ICN_NUM),
    CLAIM_HDR
         AS (SELECT
                    ICN_NUM,
    SBCR_ID,
    MBR_ID,
    MBR_FIRST_NAME,
    MBR_MI,
    MBR_LAST_NAME,
    MBR_BIRTH_DATE,
    GENDER_TYPE_CD,
    SBCR_RLTNSHP_TYPE_CD,
    SBCR_FIRST_NAME,
    SBCR_MI,
    SBCR_LAST_NAME,
    SBCR_ADDR_LINE_1,
    SBCR_ADDR_LINE2,
    SBCR_ADDR_CITY,
    SBCR_ADDR_STATE,
    SBCR_ZIP_CD,
    PRVDR_NUM,
    CLM_PRCSSD_DT,
    CLM_TYPE_CLASS_CD,
    AUTHO_NUM,
    TOT_BILLED_AMT,
    HCFA_DRG_TYPE_CD,
    FCLTY_ADMIT_DT,
    ADMIT_TYPE,
    DSCHRG_STATUS_CD,
    FILE_BILLING_NPI,
    CLAIM_LOCATION_CD,
    CLM_RELATED_ICN_1,
    SBCR_ID||0
    || MBR_ID
    || GENDER_TYPE_CD
    || SBCR_RLTNSHP_TYPE_CD
    || MBR_BIRTH_DATE
    AS MBR_ENROLL_ID,
    SUBSCR_INSGRP_NM ,
    CAC,
    PRVDR_PTNT_ACC_ID,
    BILL_TYPE,
      PAYEE_ASSGN_CODE,
    CREAT_RUN_CYC_EXEC_SK,
    PRESTG_INSRT_DT
    FROM CCP_STG.CLM_HEADER_PRESTG P WHERE ACT_CD <>'D' AND SUBSTR(CLM_PRCSS_TYPE_CD,4,1) NOT IN  ('1','2','3','4','5','6')  ),
    PROV AS ( SELECT DISTINCT
    PROV_ID,
    PROV_FST_NM,
    PROV_MD_NM,
    PROV_LST_NM,
    PROV_BILL_ADR1,
    PROV_BILL_CITY,
    PROV_BILL_STATE,
    PROV_BILL_ZIP,
    CASE WHEN PROV_SEC_ID_QL='E' THEN PROV_SEC_ID
    ELSE NULL
    END AS PROV_SEC_ID,
    PROV_ADR1,
    PROV_CITY,
    PROV_STATE,
    PROV_ZIP
    FROM CCP_STG.DAILY_PROV_PRESTG),
    MBR_XREF AS (SELECT SUBSTR(MBR_ENROLL_ID,1,17)||DECODE ((SUBSTR(MBR_ENROLL_ID,18,1)),'E','1','S','2','D','3')||SUBSTR(MBR_ENROLL_ID,19) AS MBR_ENROLLL_ID,
      NEW_MBR_FLG
    FROM CCP_STG.CCP_MBRSHP_XREF)
    SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
    CLAIM_HDR.SBCR_ID AS SBCR_ID,
    CLAIM_HDR.MBR_ID AS MBR_ID,
    CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
    CLAIM_HDR.MBR_MI AS MBR_MI,
    CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
    CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
    CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
    CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
    CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
    CLAIM_HDR.SBCR_MI AS SBCR_MI,
    CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
    CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
    CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
    CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
    CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
    CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
    CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
    CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
    CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
    CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
    CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
    CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
    CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
    CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
    CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
    CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
    CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
    CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
    CLAIM_HDR.SUBSCR_INSGRP_NM,
    CLAIM_HDR.CAC,
    CLAIM_HDR.PRVDR_PTNT_ACC_ID,
    CLAIM_HDR.BILL_TYPE,
    CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
    CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
    CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
    PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
    PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
    PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
    PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
    PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
    PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
    PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
    PROV.PROV_SEC_ID AS BILL_PROV_EIN,
    PROV.PROV_ID AS SERV_FAC_ID    ,
    PROV.PROV_ADR1 AS SERV_FAC_ADDR1          ,
    PROV.PROV_CITY AS SERV_FAC_CITY ,
    PROV.PROV_STATE AS SERV_FAC_STATE          ,
    PROV.PROV_ZIP AS     SERV_FAC_ZIP  ,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
    CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
    CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
      CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
    CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK
      FROM CLAIM_DTL,(select * FROM CCP_STG.CLM_DETAIL_PRESTG WHERE ACT_CD <>'D') CLM_DETAIL_PRESTG, CLAIM_HDR,CCP_STG.MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
    WHERE    
    CLAIM_HDR.ICN_NUM = CLM_DETAIL_PRESTG.ICN_NUM
    AND       CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
    AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
    AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
    AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
    AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
    AND CLM_DETAIL_PRESTG.FIRST_SRVC_DT >= 20110101
    AND MBR_XREF.NEW_MBR_FLG = 'Y'
    AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
    AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0
    UNION ALL
    SELECT DISTINCT CLAIM_HDR.ICN_NUM AS ICN_NUM,
    CLAIM_HDR.SBCR_ID AS SBCR_ID,
    CLAIM_HDR.MBR_ID AS MBR_ID,
    CLAIM_HDR.MBR_FIRST_NAME AS MBR_FIRST_NAME,
    CLAIM_HDR.MBR_MI AS MBR_MI,
    CLAIM_HDR.MBR_LAST_NAME AS MBR_LAST_NAME,
    CLAIM_HDR.MBR_BIRTH_DATE AS MBR_BIRTH_DATE,
    CLAIM_HDR.GENDER_TYPE_CD AS GENDER_TYPE_CD,
    CLAIM_HDR.SBCR_RLTNSHP_TYPE_CD AS SBCR_RLTNSHP_TYPE_CD,
    CLAIM_HDR.SBCR_FIRST_NAME AS SBCR_FIRST_NAME,
    CLAIM_HDR.SBCR_MI AS SBCR_MI,
    CLAIM_HDR.SBCR_LAST_NAME AS SBCR_LAST_NAME,
    CLAIM_HDR.SBCR_ADDR_LINE_1 AS SBCR_ADDR_LINE_1,
    CLAIM_HDR.SBCR_ADDR_LINE2 AS SBCR_ADDR_LINE2,
    CLAIM_HDR.SBCR_ADDR_CITY AS SBCR_ADDR_CITY,
    CLAIM_HDR.SBCR_ADDR_STATE AS SBCR_ADDR_STATE,
    CLAIM_HDR.SBCR_ZIP_CD AS SBCR_ZIP_CD,
    CLAIM_HDR.PRVDR_NUM AS PRVDR_NUM,
    CLAIM_HDR.CLM_PRCSSD_DT AS CLM_PRCSSD_DT,
    CLAIM_HDR.CLM_TYPE_CLASS_CD AS CLM_TYPE_CLASS_CD,
    CLAIM_HDR.AUTHO_NUM AS AUTHO_NUM,
    CLAIM_HDR.TOT_BILLED_AMT AS TOT_BILLED_AMT,
    CLAIM_HDR.HCFA_DRG_TYPE_CD AS HCFA_DRG_TYPE_CD,
    CLAIM_HDR.FCLTY_ADMIT_DT AS FCLTY_ADMIT_DT,
    CLAIM_HDR.ADMIT_TYPE AS ADMIT_TYPE,
    CLAIM_HDR.DSCHRG_STATUS_CD AS DSCHRG_STATUS_CD,
    CLAIM_HDR.FILE_BILLING_NPI AS FILE_BILLING_NPI,
    CLAIM_HDR.CLAIM_LOCATION_CD AS CLAIM_LOCATION_CD,
    CLAIM_HDR.CLM_RELATED_ICN_1 AS CLM_RELATED_ICN_1,
    CLAIM_HDR.SUBSCR_INSGRP_NM,
    CLAIM_HDR.CAC,
    CLAIM_HDR.PRVDR_PTNT_ACC_ID,
    CLAIM_HDR.BILL_TYPE,
    CLAIM_DTL.FIRST_SRVC_DT AS FIRST_SRVC_DT,
    CLAIM_DTL.LAST_SRVC_DT AS LAST_SRVC_DT,
    CLAIM_DTL.PLC_OF_SRVC_CD AS PLC_OF_SRVC_CD,
    PROV.PROV_LST_NM AS BILL_PROV_LST_NM,
    PROV.PROV_FST_NM AS BILL_PROV_FST_NM,
    PROV.PROV_MD_NM AS BILL_PROV_MID_NM,
    PROV.PROV_BILL_ADR1 AS BILL_PROV_ADDR1,
    PROV.PROV_BILL_CITY AS BILL_PROV_CITY,
    PROV.PROV_BILL_STATE AS BILL_PROV_STATE,
    PROV.PROV_BILL_ZIP AS BILL_PROV_ZIP,
    PROV.PROV_SEC_ID AS BILL_PROV_EIN,
    PROV.PROV_ID AS SERV_FAC_ID    ,
    PROV.PROV_ADR1 AS SERV_FAC_ADDR1          ,
    PROV.PROV_CITY AS SERV_FAC_CITY ,
    PROV.PROV_STATE AS SERV_FAC_STATE          ,
    PROV.PROV_ZIP AS     SERV_FAC_ZIP  ,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_1,
    CHK_PAYMNT.CLM_PMT_PAYEE_ADDR_LINE_2,
    CHK_PAYMNT.CLM_PMT_PAYEE_CITY,
    CHK_PAYMNT.CLM_PMT_PAYEE_STATE_CD,
    CHK_PAYMNT.CLM_PMT_PAYEE_POSTAL_CD,
    CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK  
      FROM CLAIM_DTL, CLAIM_HDR,MBR_XREF,PROV,CCP_STG.CLM_PAYMNT_CLMEXT_PRESTG CLM_PAYMNT,CCP_STG.CLM_PAYMNT_CHKEXT_PRESTG CHK_PAYMNT
    WHERE CLAIM_HDR.ICN_NUM = CLAIM_DTL.ICN_NUM
    AND CLAIM_HDR.ICN_NUM=CLM_PAYMNT.ICN_NUM(+)
    AND CLM_PAYMNT.CLM_PMT_CHCK_ACCT=CHK_PAYMNT.CLM_PMT_CHCK_ACCT
    AND CLM_PAYMNT.CLM_PMT_CHCK_NUM=CHK_PAYMNT.CLM_PMT_CHCK_NUM
    AND CLAIM_HDR.MBR_ENROLL_ID = MBR_XREF.MBR_ENROLLL_ID
    -- AND TRUNC(CLAIM_HDR.PRESTG_INSRT_DT) = TRUNC(SYSDATE)
    AND CLAIM_HDR.CREAT_RUN_CYC_EXEC_SK = 123638.000000000000000
    AND MBR_XREF.NEW_MBR_FLG = 'N'
    AND PROV.PROV_ID(+)=SUBSTR(CLAIM_HDR.PRVDR_NUM,6)
    AND MOD(SUBSTR(CLAIM_HDR.ICN_NUM,14,2),2)=0;

  • Improving SQL query for large records.

    I need to extract the difference on the table t1 and t2(contains both almost 6M records). Im looking specifically on the two columns (c1,c2)for my comparison.I need also to look at reference table to extract also other fields for my report. thank you
    Dynamic Table (same table and structure but different records.)
    t1
    t2
    Reference Static Table (all the tables below have two columns. c1 and c2 used for reference only)
    t3
    t4
    t5
    --Extracting data in t1 but not exists in t2
    WITH v1 AS(SELECT c2,c3,c4 FROM t1 at1
    WHERE NOT EXISTS (SELECT 'x' FROM t2 at2 WHERE at1.c1 = at2.c2)),
    v2 AS (SELECT c1, c2 FROM t3),
    v3 AS (SELECT c1, c2, c3 FROM t4),
    v4 AS (SELECT c1,c2 FROM t5)
    SELECT v1.c1, v1.c2, v3.c2, v4.c2 FROM t,t2,t3,t4
    WHERE v1.c1 = v2.c1
    AND v2.c2 = v3.c1
    AND v3.c2 = v4.c1
    ORDER BY v1.c1
    I'm trying to improve my scripts to generate the record as fast as possible coz it takes too long. Any suggestions guys.? Im trying to look also on explain plan but I'm new on this. thank you

    Hi,
    your sample code can not compile?
    There is no column c1 in the v1?
    Probably a typo anyway :)
    A couple of remarks:
    The way you've used v1, v2, v3 and v4 does not help performance.
    It only helps increasing the confusion.
    Rewrite the query without the WITH clause, post the execution plan for the query and report your Oracle version and we can help you further.
    / Ronnie

Maybe you are looking for

  • New quad and lots of force quits

    hi i just got my G5 quad and i have instaled FCP studio but it seems like i have to do a lot of force quits on it. can anyone help me. and when i export a movie that is about an hour long it takes about 3 to 4 hours to export when using quick time co

  • Print out of GR(Urgent)

    Dear Experts, I have got a requirement like this.... When user does MIGO transaction,after saving a particular document immidiately user needs a print out of that Goods Receipt. Can any one tell me how to get this??? Thanks and Regards MK

  • How to get the empty image box?

    Hi, i have an form.In that form i want empty image box to upload picture like orkut etc. How can i achieve this? Regards D.Mahesh babu

  • Can I create a field to upload larger photo files?

    I need to have a field for people to upload images, both photos and graphic design images but when I try and use the basic "upload a file" field the user gets a message saying the file cannot be over 100KB. Is there any way to allow them to send larg

  • Cannot find the object "CrossRef" in Active Directory

    I am trying to install Lync 2013. I'm getting the following error: Error: An error occurred: "Microsoft.Rtc.Management.Deployment.ActiveDirectoryException" "Cannot find the object "CrossRef" in Active Directory." WARNING: Enable-CSAdForest failed. Th