Query help to find missing rows

Hi,
Create tableA (
columname varchar2;
Insert into tableA ('a3');
Insert into tableA ('dd');
Select * from tablename where column in ( a3, b12,c34, dd ); -- 4 Values provided
Need a query to return b12,c34 ie I have to find which records or not returning from a table for a given values.
Please help
Thanks
Arvy
Edited by: ARVY on Jun 19, 2012 11:10 AM
Edited by: ARVY on Jun 19, 2012 11:16 AM

ARVY wrote:
I am using Oracle 9i versionFollowing is query that should be compatible on 9i.
Please test it,since I am not able to do it due to unavailability of Oracle 9i with me.
with data as
  select 'a,b,c,d' || ',' col from dual
isolated_data as
  select trim(both ',' from (substr(col,
              DECODE(level,
                      1, 1,
                      instr(col, ',', 1, level - 1) + 1
              DECODE(level,
                      1, instr(col, ',', 1, level),
                      instr(col, ',', 1, level) - instr(col, ',', 1, level - 1)
             ) ))col1
    from data
   connect by level <= length(col) - length(replace(col, ','))
select a.col1
  from isolated_data a
where a.col1 NOT IN (select col from test_Table);Regards,
P.

Similar Messages

  • Sql Query Help to find values?

    Hi! 
    i have a table structure like this...
    you can see the image here.
    http://postimg.org/image/3k5nvkvn5/
    i which i need to find some values.
    Example: i need to find all column "District" values where value=46
    then in that case you can see in above image that row 1 to 4 has to fetched because these columns contains value between 45-52, also in row 5 where value is 46,47 the also it  has to be fetched, here i have to kind of structure to be used in table one
    is comma separated and another one is comma and dash separated value, so how can i find these values in table. so how can achieve this using query, Any help would be triplicated.

    Ah this is not correct way to store data in table
    If you store like this you've to do lots of manipulations before values can be used in  filter
    So as per above you would require something like this
    ;With Numbers(N)
    AS
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    Num_Matrix(N)
    AS
    SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1))
    FROM Numbers n1
    CROSS JOIN Numbers n2
    CROSS JOIN Numbers n3
    CROSS JOIN Numbers n4
    CROSS JOIN Numbers n5
    CROSS JOIN Numbers n6
    CROSS JOIN Numbers n7
    CROSS JOIN Numbers n8
    SELECT DISTINCT t.po_city_st_zip
    FROM
    SELECT LEFT(f.Val,CHARINDEX('-',f.Val+'-')-1) AS StartVal,
    STUFF(f.Val,1,CHARINDEX('-',f.Val+'-'),'') AS EndVal,
    t.*
    FROM YourTable t
    CROSS APPLY do.ParseValues(t.District,',')f
    )m
    INNER JOIN Num_Matrix n
    ON n.N BETWEEN m.StartVal AND m.EndVal
    WHERE n.N = <your Value>
    See ParseValues UDF here                                                                 
    http://visakhm.blogspot.ae/2010/02/parsing-delimited-string.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Query help: Return mult. matching rows only, single table...

    I've done some searching - but no luck - I have a question that should be easy for an expert:
    I want to select only rows that have multiple occurences of matching fields - and I don't know (or really care) what their values are.
    Example table has 5 fields: field1 field2 field3 field4 field5
    If there is more than 1 record that share the same field1, field3, and field5 - then I want to return all of those records, and ignore the rest.
    Finally, I don't know what the matching values are or may be - they just match. I do, however, know it has to be those 3 fields (only fields 1, 3 and 5).
    field1 field2 field3 field4 field5
    1 ???? John ???? Seattle
    1 ???? John ???? Spokane
    2 ???? John ???? Seattle
    1 ???? John ???? Spokane
    So from the above, I would only want 2 rows - both:
    1 ???? John ???? Spokane
    Because those 3 fields matched up in multiple rows, it the ???? fields that I want to look at in both rows.
    I really appreciate any help in advance!

    Hi,
    An other solution :
    SQL> select * from tbl;
        FIELD1 FIELD2     FIELD3     FIELD4     FIELD5
             1 ????       John       ????       Spokane
             2 ????       John       ????       Seattle
             1 ????       John       ????       Spokane
             1 ????       John       ????       Seattle
    SQL> select distinct field1,field2,field3,field4,field5
      2  from (select tbl.*,count(*) over (partition by field1, field3,field5) ct from tbl)
      3  where ct >1;
        FIELD1 FIELD2     FIELD3     FIELD4     FIELD5
             1 ????       John       ????       Spokane
    SQL> Nicolas.
    Message was edited by:
    N. Gasparotto
    With a field3 value like this, it's necessary John which answered first ;-)

  • Finding missed sequence numbers and rows from a fact table

    Finding missed sequence numbers and rows from a fact table
    Hi
    I am working on an OLAP date cube with the following schema:
    As you can see there is a fact transaction with two dimensions called cardNumber and Sequence. Card dimension contains about three million card numbers. 
    Sequence dimension contains a sequence number from 0 to 255. Fact transaction contains about 400 million transactions of those cards.
    Each transaction has a sequence number in 0 to 255 ranges. If sequence number of transactions of a card reaches to 255 the next transaction would get 0 as a sequence number.
    For example if a card has 1000 transactions then sequence numbers are as follows;
    Transaction 1 to transaction 256 with sequences from 0 to 255
    Transaction 257 to transaction 512 with sequences from 0 to 255
    Transaction 513 to transaction 768 with sequences from 0 to 255
    Transaction 769 to transaction 1000 with sequences from 0 to 231
    The problem is that:
    Sometimes there are several missed transactions. For example instead of sequence from 0 to 255, sequences are from 0 to 150 and then from 160 to 255. Here 10 transactions have been missed.
    How can I find all missed transactions of all cards with a MDX QUERY?
    I really appreciate for helps

    Thank you Liao
    I need to find missed numbers, In this scenario I want the query to tell the missed numbers are: 151,152,153,154,155,156,157,158,159
    Relative transactions are also missed, so I think it is impossible to get them by your MDX query
    Suppose this:
    date
    time
    sequence
    20140701
    23:22:00
    149
    20140701
    23:44:00
    150
    20140702
    8:30:00
    160
    20140702
    9:30:00
    161
    20140702
    11:30:00
    162
    20140702
    11:45:00
    163
    As you can see the sequence number of the last transaction at the 20140701 is 150
    We expecting that the first transaction of the next day should be 151 but it is 160. Those 10 transactions are totally missed and we just need to
    find missed sequence numbers

  • Find the index of a missing row

    Hello,
    I would like some help in designing this query. For example i have a table with these record.
    ID_BOOK | Name | Surname
    1               Name1 SurName1
    2               Name2 Surname2
    3  Name3 Surname3
    4   
     Name4 Surname4
    6  Name6 Surname6
    where ID_BOOk is a primary key
    For example the missing row of 5 was previously deleted and i have no information about it. I need to write a query for  the value of the primary key that was deleted by the previous query or if none of the rows werent deleted i want the last row or
    at least turn 0. I also need to implement this in LINQ in C# but at least need the logic in SQL. Thank you very much. 

    Hello,
    This should work for you: Self JOIN on the table over ID_BOOK whereby you add 1 on the right side, then check if rows don't return a right record =>
    SELECT SRC.ID_BOOK + 1 AS MissingID
    FROM yourTable AS SRC
    LEFT JOIN
    yourTable AS DST
    ON SRC.ID_BOOK = (DST.ID_BOOK + 1)
    WHERE DST.ID_BOOK IS NULL
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Help with Finding Duplicate records Query

    HI,
    I am trying to write a query that will find duplicate records/cases.
    This query will be used in a report.
    So, here are the requirements:
    I need to find duplicate cases/records based on the following fields:
    DOB, DOCKET, SENT_DATEI was able to do that with the following query. The query below is able to give me all duplicate records based on the Criteria above
    SELECT      DEF.BIRTH_DATE DOB,
               S.DOCKET DOCKET,
               S.SENT_VIO_DATE SENT_DATE, COUNT(*)
    FROM SENTENCES S,
                DEFENDANTS DEF
    WHERE      S.DEF_ID = DEF.DEF_ID
    AND       S.CASE_TYPE_CODE = 10
    GROUP BY  DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE
    HAVING COUNT(*) > 1;
    //I AM GOING TO CALL THIS QUERY 'X'Now, the information to be displayed on the report: defendants Name, DOB, District, Docket, Def Num, Sent Date, and PACTS Num if possible.
    The problem that I need help on is how to combine those queries together (what I mean is a sub query). the 'X' query returns multiple values. please have a look at the comments on the query below to see what I'm trying to achieve.
    here is the main query:
    SELECT      INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
    FROM      USSC_CASES.DEFENDANTS DEF,
            USSC_CASES.SENTENCES S,
            LOOKUP.DISTRICTS DIST
    WHERE      DEF.DEF_ID = S.DEF_ID
    AND      S.DIST_ID = DIST.USSC_DISTRICT_ID
    AND     S.CASE_TYPE_CODE = 10
    AND     S.USSC_ID IS NOT NULL
    AND // what i'm trying to do is: DOB, DOCKET, SENT_DATE IN ('X' QUERY), is this possible ??
    ORDER BY DEFENDANT_NAME; thanks in advance.
    I am using Oracle 11g, and sql developer.
    if my approach doesn't work, is there a better approach ?
    Edited by: Rooney on Jul 11, 2012 3:50 PM

    If I got it right, you want to join table USSC_CASES.DEFENDANTS to duplicate rows in USSC_CASES. If so:
    SELECT  INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
      FROM  USSC_CASES.DEFENDANTS DEF,
             SELECT  *
               FROM  (
                      SELECT  S.*,
                              COUNT(*) OVER(PARTITION BY DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE) CNT
                        FROM  USSC_CASES.SENTENCES S
               WHERE CNT > 1
            ) S,
            LOOKUP.DISTRICTS DIST
      WHERE DEF.DEF_ID = S.DEF_ID
       AND  S.DIST_ID = DIST.USSC_DISTRICT_ID
       AND  S.CASE_TYPE_CODE = 10
       AND  S.USSC_ID IS NOT NULL
      ORDER BY DEFENDANT_NAME;If you want to exclude duplicates from the query and do not care which row out of duplicate rows to choose:
    SELECT  INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
      FROM  USSC_CASES.DEFENDANTS DEF,
             SELECT  *
               FROM  (
                      SELECT  S.*,
                              ROW_NUMBER() OVER(PARTITION BY DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE ORDER BY 1) RN
                        FROM  USSC_CASES.SENTENCES S
               WHERE RN = 1
            ) S,
            LOOKUP.DISTRICTS DIST
      WHERE DEF.DEF_ID = S.DEF_ID
       AND  S.DIST_ID = DIST.USSC_DISTRICT_ID
       AND  S.CASE_TYPE_CODE = 10
       AND  S.USSC_ID IS NOT NULL
      ORDER BY DEFENDANT_NAME;SY.

  • How to find out which sub query returns more than one row

    Hi all,
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .
    /* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
    SELECT a.*, ROWNUM AS rnm
      FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
                            prxm.mbr_idntfr AS "Beneficiary ID",
                               md.last_name
                            || ', '
                            || md.first_name AS "Beneficiary Name",
                            pci.idntfr AS "Tracking No.",
                            TO_CHAR (TRUNC (req.pa_rqst_date),
                                     'MM/dd/yyyy'
                                    ) AS "Request Date",
                            sts.status_name AS "Status",
                            req.pa_rqst_sid AS "Request #",
                            prxm.mbr_sid AS "Mbr_sid",
                            TO_CHAR
                                  (TRUNC (req.pa_revision_date),
                                   'MM/dd/yyyy'
                                  ) AS "Last Updated",
                            TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
                            prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
                            pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
                            DECODE
                               ((SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                0, (SELECT prxplo.prvdr_lctn_idntfr
                                      FROM pa_request_x_provider_location prxplo
                                     WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                       AND prxplo.oprtnl_flag = 'A'
                                       AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT prxplo.prvdr_lctn_idntfr
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "NPI/ID",
                            DECODE
                               ((SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT    pd.last_name
                                              || ', '
                                              || pd.first_name
                                              || ' '
                                              || pd.middle_name
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "Prvdr Name",
                            TO_CHAR (psd.from_date,
                                     'MM/dd/yyyy'
                                    ) AS "Srvc From Date",
                            TO_CHAR (req.validity_start_date,
                                     'MM/DD/YYYY'
                                    ) AS "Due Date",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>Left",
                            req.pa_mode_type_lkpcd AS "Source",
                            TO_CHAR (TRUNC (wmdtl.rtng_date),
                                     'MM/dd/yyyy'
                                    ) AS "Assigned On",
                            NVL (wmdtl.assigned_to_user_name,
                                 'Not Assigned'
                                ) AS "Assigned To",
                            req.org_unit_sid AS "OrgUnitSid",
                            TO_CHAR
                                 (wmdtl.modified_date,
                                  'MM/dd/yyyy hh24:mi:ss'
                                 ) AS "WTRD_MODIFIED_DATE",
                            TO_CHAR (wmdtl.rtng_date,
                                     'MM/dd/yyyy'
                                    ) AS "WTRD_RTNG_DATE",
                            req.status_cid AS "PA_STATUS_CID",
                            TO_CHAR (req.modified_date,
                                     'MM/dd/yyyy'
                                    ) AS "PA_REQ_MODIFIED_DATE",
                            prs.state_pa_srvc_type_code
                                                     AS "STATE_PA_SRVC_TYPE_CODE",
                            wmdtl.wm_pa_task_rtng_dtl_sid
                                                        AS "WM_TASK_RTNG_DTL_SID",
                            wmdtl.assigned_to_user_acct_sid
                                              AS "WTRD_Assigned_to_user_acct_sid",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>LeftSort",
                            wmdtl.assigned_to_org_unit_sid
                                                  AS "WTRD_Assigned_to_OrgUntSid",
                            DECODE
                               ((SELECT COUNT (*)
                                   FROM pa_request_status prs
                                  WHERE prs.pa_rqst_sid = req.pa_rqst_sid
                                    AND prs.status_cid = 5
                                    AND prs.oprtnl_flag = 'I'),
                                0, 'N',
                                'Y'
                               ) AS "SHOW_UTILIZATION"
                       FROM   pa_request req,
                             pa_certification_identifier pci,
                             status sts,
                             pa_request_x_member prxm,
                             wm_pa_task_routing_detail wmdtl,
                             pa_service_date psd,
                             org_unit ou,
                             pa_request_service prs,
                             pa_request_x_provider_location prxpl,
                             provider_location pl,
                             provider_detail pd,
                             provider p,
                             mbr_dmgrphc md
                      WHERE req.oprtnl_flag = 'A'
                        AND req.status_cid NOT IN
                                     (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
                        AND req.org_unit_sid IN
                               (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
                                3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
                                3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
                                3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
                                3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
                                3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
                                3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
                                3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
                                3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
                                3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
                                3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
                                3101, 3186, 3102, 3187, 3103, 3003, 75000104,
                                75000108, 2006, 75000103, 75000102, 75000113,
                                75000111, 75000109, 2001, 2009, 75000105,
                                75000107, 2004, 2010, 2013, 2014, 2005, 2011,
                                75000112, 2002, 1001, 2012, 75000106, 2007,
                                75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
                                3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
                                3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
                                3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
                                3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
                                3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
                                3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
                                3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
                                3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
                                3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
                                3140, 3056, 3141)
                        AND req.pa_rqst_sid = prs.pa_rqst_sid
                        AND prs.oprtnl_flag = 'A'
                        AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
                        AND psd.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = pci.pa_rqst_sid
                        AND pci.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxm.pa_rqst_sid
                        AND prxm.oprtnl_flag = 'A'
                        AND md.oprtnl_flag = 'A'
                        AND md.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
                        AND prxm.mbr_sid = md.mbr_sid
                        AND ou.org_unit_sid = req.org_unit_sid
                        AND ou.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND pci.pa_rqst_sid = prxm.pa_rqst_sid
                        AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
                        AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxpl.pa_prvdr_type_lkpcd = 'RR'
                        AND prxpl.oprtnl_flag = 'A'
                        AND req.status_cid = sts.status_cid
                        AND sts.status_type_cid = 3
                        AND sts.oprtnl_flag = 'A'
                        AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
                        AND p.prvdr_sid = pd.prvdr_sid
                        AND p.prvdr_sid = pl.prvdr_sid
                        AND pd.oprtnl_flag = 'A'
                        AND pd.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
                        AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
                        AND wmdtl.subsystem_lkpcd = 'PA'
                        AND wmdtl.oprtnl_flag = 'A'
                        AND req.pa_rqst_date > (SYSDATE - 365)
                                       ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
                            "Beneficiary Name" ASC) a
    WHERE ROWNUM < 102;regards,
    P Prakash
    Edited by: BluShadow on 17-May-2011 15:01
    added {noformat}{noformat} tags around the code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    833560 wrote:
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .This is why smaller, simpler queries are easier to work with than huge ones - when something like this goes wrong smaller queries are much eaiser to debug. Unfortunately using smaller, easier-to-work with queries is not always an option
    Ganesh is right - you will have to dissect the big query bit by bit until you find the offending subquery. If there is another way I would like to find out about it too.
    The easiest way to do this is probably to use block comments to isolate parts of the query bit by bit until you find the offending part. If you carefully examine the subqueries you might be able to figure out which one is returning multiple rows without commenting everything
    Good luck!

  • How to find duplicate row in sql query?

    Hi All,
    Please solve my query, find duplicate row and how to count its. your suggestion would be greatly appreciated.

    You can use group by and having.
    SQL> WITH t
      2       AS (SELECT       LEVEL id
      3                 FROM   DUAL
      4           CONNECT BY   LEVEL <= 5
      5           UNION ALL
      6           SELECT       LEVEL + 2
      7                 FROM   DUAL
      8           CONNECT BY   LEVEL <= 3)
      9  SELECT   *
    10    FROM   t;
            ID
             1
             2
             3
             4
             5
             3
             4
             5
    8 rows selected.
    SQL> WITH t
      2       AS (SELECT       LEVEL id
      3                 FROM   DUAL
      4           CONNECT BY   LEVEL <= 5
      5           UNION ALL
      6           SELECT       LEVEL + 2
      7                 FROM   DUAL
      8           CONNECT BY   LEVEL <= 3)
      9  SELECT     id, COUNT (*)
    10      FROM   t
    11  GROUP BY   id
    12    HAVING   COUNT (*) > 1;
            ID   COUNT(*)
             3          2
             4          2
             5          2
    SQL>

  • Help me find my missing "CashFlow HD" data from my ipad!

    I turned on my ipad this afternoon and found 12 months of data missing from CashFlow HD.  My husband transfered some music from the imac to the ipad today and he says the data was there this morning when he put in today's purchases.  Can anyone help me find my data?

    Chris,
    Don't quote me on this but here is a possible solution to your problem.
    First get all your music files from your usb data stick or external hard drive and copy/cut (your choice) and paste the songs into your itunes music folder.
    Once thier in your itunes music folder drag and drop them into your itunes library.
    If that doesn't work
    Take all your songs off of your usb data or your external hard drive stick and place them on your desktop.
    Once the songs are on your desktop, drag and drop them into iTunes.
    Once the songs are in iTunes go to Advanced> Consolidate Libary
    (this takes all of your music files and places them into the iTunes music folder.)
    Then you can take all of your music files and place them in a folder in your my music folder.
    Again I cant guarantee this will work if it doesn't you will just have to import your songs the long way.
    Also when all your music works you should make a back-up disc in iTunes that way if your computer crashes you can just insert the backup disc and it will restore all of your iTunes music, podcasts, games for your iPod, and movies.
    To learn how to do this see this link:
    http://docs.info.apple.com/article.html?path=iTunesWin/7.5/en/15337.html
    Hope this Helps,
    DJFX

  • Updating/Find Missing *Drive* Query

    Good day to you all
    I'm looking for a way to apply the "Find Missing Folder.." function to the actual drive. Essentially using the Drive letter as the parent "folder" to sync all subfolders and update all the image paths.
    The scenario;
    I had all my photos on a local drive "W:".
    They are now all on a network drive - we'll call this \\NAS\Photos (where photos is the share name on the network drive)
    I can manually go through the "missing" folders from W: in the left pane of the library and "Find Missing Folders.." one at a time. This works.
    However, I have about 100 folders so this is very time consuming.
    The folder structure is exactly the same, what I would like to do is update the DRIVE path so I can preserve all of the LR edits.
    Any ideas?
    TIA

    So what exactly are you doing....are you trying to relink one of the missing folders to the parent folder on the NAS? Is the parent folder showing in the Folders Panel in Lightroom's Library module? If it is, that's the folder you should relink to the equivalent parent on the NAS.
    If, however, the parent folder is NOT showing in the Folders Panel, then right-click on any of the "missing" folders and select "Show Parent Folder"....that should add the parent folder to the folders panel, so that you can then relink with a single "Find Missing Folder" command (the ability to show a parent folder for missing folders was a new feature in LR4, you couldn't do that in previous versions).

  • Find Missing Folder - does not work.  Please help!

    Has anyone had this problem?  This is driving me crazy.  Any time I rename or move a folder and try to use the "Find Missing Folder" option it does not show any of my hard drives!  It has been like this through several LR updates.  I kept praying the next release of lightroom would fix this, but so far no luck.

    Did you try clicking on the left menu, on the _folder_, and selecting "Update folder location"?
    You can also try "promote parent folder" to move it up the chain and find the missing drives...
    Cheers!

  • Finding Missing Numbers

    I want to find missing numbers from a column which is alpha numeric, its last five positions are numeric. At first three positions there are different combinations of alphas i.e. *'BA ','BAW','SA ','SAA' ..........* if alphas are two then 3rd position is blank. I also need it to generalised this to cover all existing alpha numeric series.
    SELECT SUBSTR (a.claim_no, 4, 5) + 1
      FROM core_business.cb_pensioner a
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA '
       AND NOT EXISTS (
                     SELECT NULL
                       FROM core_business.cb_pensioner b
                      WHERE to_number(SUBSTR (b.claim_no, 4, 5)) =  to_number(SUBSTR (a.claim_no, 4, 5)) + 1)
       order by SUBSTR (a.claim_no, 4, 5);I am getting ORA-01722 error

    You have two issues with such a task.
    Problem 1 is how to convert the trailing part into a number so that you can compare values.
    to_number(SUBSTR (b.claim_no, 4, 5)) works, but only if the value in b.claim_no is always a number regardless of the other column criteria.
    A statement like
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA ' /* filter 1 */
    and to_number(SUBSTR (b.claim_no, 4, 5)) > 1 /* filter 2 */
    ...might fail because your table might have a value like
    b.claimno = 'XYZ1234b'
    The way you wrote the query the database will decide which filter criteria it executes first. It might be filter1, but could also be filter2. If filter2 is executed first then you will get the error message.
    Problem 2 how to order and compare different rows, so that you can find the missing values.
    Here the analytic LEAD(LAG) function is very helpful. it will give you access to the next (or previous row).
    Both problems can be overcome.
    Here is my try, but I'm not sure if it works in your case. You might need to adapt a little.
    This should work if all the rows are numeric that belong to the specific groups. if you can have wrong data in there too, then a different approach is needed.
    with testdata as (select 'XYZ1234b' claim_no from dual union all
                select 'BA 12345' claim_no from dual union all
                select 'BA 12346' claim_no from dual union all
                select 'BA 12350' claim_no from dual union all
                select 'BAW11111' claim_no from dual union all
                select 'BAW11113' claim_no from dual union all
                select 'XYZ1234b' claim_no from dual )
    /* end of test data creation */
    select claim_no, substr(claim_no, 1,3) part1, substr(claim_no, 4) part2,
           to_number(substr(claim_no, 4)) current_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4))) next_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4)))
            - 1 - to_number(substr(claim_no, 4))
            as "missing_values"
    from testdata
    where substr(claim_no, 1,3) in ('BAW','BA ')
    order by claim_no;
    CLAIM_NO PAR PART2 CURRENT_NUM   NEXT_NUM missing_values
    BA 12345 BA  12345       12345      12346              0
    BA 12346 BA  12346       12346      12350              3
    BA 12350 BA  12350       12350
    BAW11111 BAW 11111       11111      11113              1
    BAW11113 BAW 11113       11113Problem 1 is solved because the where condition is always executed before the function in the select clause, especially in connection with an analytic function.
    Problem 2 is also solved by using the analytic function LEAD function. And this is fast, because you access the same table only one time. Other solution might do a subquery to fetch the value from the previous/next row. This means several accesses to the same table and is usually much slower.
    Edited by: Sven W. on Sep 20, 2010 2:32 PM

  • Status of part query help

    Hi, I have a part, and it can be received, accepted, rejected, corrected and shipped. This is held in the status field. It is on the line level, so each part also has a line number associated with the transactions status, i.e.
    Part PO Line Status
    12345 1 Received
    12345 2 Rejected
    I need to know how many parts for each po line only have a status of rejected. They must never have been received, rejected, corrected or shipped, only received.
    I don't know where to begin, thank you for any help.

    Hi,
    The query I posted doesn't consider the order of events at all. As posted, it finds 'Rejected' rows without a matching 'Corrected' or 'Shipped' row, regardless of which came first.
    If order is important, you might be able to modify the query I posted.
    For example, the query below finds 'Rejected' rows that were not followed by "Corrected' or 'Shipped': any status *before* the 'Rejected' (sorting by po_line) is okay:
    {code}
    SELECT     *
    FROM     part_table     m     -- m for main
    WHERE     status     = 'Rejected'
    AND     NOT EXISTS (     SELECT     1
                   FROM     part_table
                   WHERE     part     = m.part
                   AND     status     IN ('Corrected', 'Shipped')
                   AND     po_line     > m.po_line          -- <== NEW
    {code}
    Depending on what you need to do, there might be better ways.
    Boneist had a good idea: post some sample data, showing different situations that you need to handle, and the results you want from that data.

  • Need help in finding open source for creating Login component

    hi
    Pls any one help me out in finding some good open source for creating login component for my application
    i have heard about josso but i am not able to find how to use it if anyone can help in setting up josso i wil be very thankful to that person and also if anyone can help me finding some other open source i will be very grateful ,,
    Pls help its very urgent and i am running short of time

    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
    I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
    You could possibly create the views as materialized views and query those instead.
    Quote from the linked article
    But, how does it perform? Miserably, terribly, horribly. A simple "select
    first_name, last_name from person" query is transformed into a 3-table join with
    aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
    might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
    outer join instead of just joining which in some cases can remove more optimal
    query plans from consideration.
    Writing queries might look pretty straightforward, but it's impossible to do in
    a performant fashion.

  • Finding Missing Time Interval in SQL

    All 
     Need help with SQL to find Missing Time Interval. 
    My query returns data as given below  
    Data1
     Column      StartTime    EndTime
    =======   =======   ======= 
    T2               9:00          18:00T3               20:00         23:00 
    Data2
     Column      StartTime    EndTime
    =======   =======   ======= T1               15:00          20:00
    T3               20:00          07:00 
    Take above output, I want to find Time Not on my Data in 24 hours from First StartTime on each Data Set.
    Example: Data1
    First StartTime: 9:00 AM (T2 record)
    Add 24 hours, which will be 9:00AM Next day.
    Expected Result to get missing time interval for Data1
    18:00 - 20:00
    23:00 - 9:00 (next day)
    For Data2 Expected result
    7:00 - 15:00 Next Day
    Database version: 11g
    Anyone come across to calculate missing time interval? Can I use PL/SQL for this like pipeline function?
    Any help/directions/references I highly appreciate.
    Thanks in advance.
    Karth

    One way of finding Missing Intervals:
    alter session set nls_date_format = 'DD-Mon-YYYY HH24:MI:SS';
    with data as
      select to_date('28-Jun-2013 09:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 18:00', 'DD-Mon-YYYY HH24:MI') end_time from dual union all
      select to_date('28-Jun-2013 20:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 23:00', 'DD-Mon-YYYY HH24:MI') end_time from dual
    select start_time, end_time,
           case when lead(to_char(start_time, 'HH24'), 1, (select min(to_char(start_time, 'HH24')) from data)) over (order by to_char(start_time, 'HH24')) not between to_char(start_time, 'HH24') and to_char(end_time, 'HH24')
                  then to_char(end_time, 'HH24:MI') || ' - ' || lead(to_char(start_time, 'HH24:MI'), 1, (select min(to_char(start_time, 'HH24:MI')) from data)) over (order by to_char(start_time, 'HH24:MI'))
                else
                  null
           end period
      from data
    START_TIME                END_TIME                  PERIOD      
    28-Jun-2013 09:00:00      28-Jun-2013 18:00:00      18:00 - 20:00
    28-Jun-2013 20:00:00      28-Jun-2013 23:00:00      23:00 - 09:00
    Time information need not be stored in additional Varchar fields, if you have Date Column. You can use Date fields that store Date and time both.
    Another way of approaching this problem is with Connect By Clause or Model Clause. Use the search functionality to find solutions using those methods too. However, in my opinion, this method is the quickest of all.

Maybe you are looking for

  • How to view the PML mesages in SAP AII ?

    Hi Experts, I am new SAP AII. I want to view the PML Messages in SAP AII sent from the Edge management software. How can i do that ? Thanks, Arkesh

  • Unable to launch Instant Messaging Service

    Hi, I have a IM channel deployed on a portal desktop as one of the portlet. When I click Launch Instant Messanger in IM channel , following error is displayed: "Unable/Cannot to launch Instant Messaging" . I am not getting to know why this error is d

  • Proper method for building kernel modules? [solved]

    I am attempting to build a custom kernel module for a PCI express interface to an FPGA.  However, I seem to be running into some issues with getting the standard kernel module makefile to work correctly.  Here is my makefile: # object files to build

  • JavaScript error on WD

    Hi Friends, the same issue, opening again. I am getting JavaScript error on WebDynpro aplication. The error is "Object Required on line number .." because of this, when I run the aplication on browser IE6.0 build 2900.2180, SP2, the application manag

  • Personal Actions in Om

    Hi Gurus, Can some one please explain what are <b>Personal Actions in Organizational Management</b>, how are they useful, how are they configured in SAP. Thanks for all the help in advance. Krishna