Query - Find Master Records - Doesnt Child Rec

Hello Experts,
BANNER
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
Below is my table - ORG_VALUE
ITEM_ID  ITEM_TYPE ORG_ID
1000     TEST      222
1000     TEST_1    223
2000     TEST      322
2000     TEST_1    323
3000     TEST      222
4000     TEST      322222,322- Master Org id... 223,323 - Child Org id
I need to fetch those records which doesnt have child record for particular item in same table.
E.g; if 1000 item_id for 222 org id, then def. there should be child record 1000 for 223 org_id.
Similar for 322 and 323.
OUTPUT
ITEM_ID  ITEM_TYPE ORG_ID
3000     TEST      222
4000     TEST      322Tried the following query...
SELECT     *
FROM          ORG_VALUE a
WHERE      NOT EXISTS (SELECT     1  FROM     ORG_VALUE b
          WHERE      a.item_id = b.item_id
                            and org_id IN (223, 323))
order by item_id;Is there any other query better than this one>?
Please help...

Like this (assuming child org ID always ends with 3)?
  1  WITH d AS (
  2  SELECT 1000 as item_id, 'TEST' as item_type, 222 AS org_id  FROM dual UNION ALL
  3  SELECT 1000,'TEST_1', 223 FROM dual UNION ALL
  4  SELECT 2000,'TEST', 322 FROM dual UNION ALL
  5  SELECT 2000,'TEST_1', 323 FROM dual UNION ALL
  6  SELECT 3000,'TEST', 222 FROM dual UNION ALL
  7  SELECT 4000,'TEST', 322 FROM dual)
  8* SELECT item_id FROM d GROUP BY item_id HAVING(MAX(MOD(org_id,10))) != 3
SQL> /
   ITEM_ID
      4000
      3000Lukasz

Similar Messages

  • Query find no records in Enter Quality Results Form (QLTRSMDF)

    Hi,experts
    When execute query (F11/ctrl F11) in Enter Quality Results Form (QLTRSMDF) for a particular plan,say I want to query all results in that plan,it found nothing.
    In system block/last query, found that it uses occurrence and collection_id which is newly created.
    And compare with the SQL used in Update Quality Results Form,there are different conditions used,say org_id is used in the Update form.
    Is it okay to query results in Enter Quality Results Form (QLTRSMDF) of a plan?
    or it is designed to use the Update form to query and update?
    Thanks in advance!
    Morris

    No you have to use the View Quality Results Form (QLTRSINF) to see already entered collection results. The enter form is only to enter new collection results.

  • Personnel master record & not found (check entry) Message RU040

    Dear Friends,
    Error message RU040 is observed when confirmation is posted in CO11N for Personnel No.
    However, with same data confirmation is successfully posted in quality server but in Production server it is giving error.
    So I am confused why system is giving this error only in Production server & not in quality server even though Personnel Master record doesnt exist in both the servers.
    Kindly share your views for the same.
    Thanks in advance.
    Regards,
    Tejas

    Hi Hiren,
    Thanks for your reply. But actually my issue is different. Actually When personnel no. field value is maintained in Produciton server while confirmation in CO11N by user it is throwing above error since no personnel master record maintained same is the case in quality server but to my surprise system is allowing to save confirmation without throwing above error in quality.
    I checked CO86 part but it is not relavant to this issue.
    Regards,
    Tejas

  • How to find out the account group information in customer master record?

    how to find out the account group information in customer master record?
    in which tab? thanks in advance

    Hi
    Go to XD02 and select the Extras from the main menu , you will find Account group info -> click on the No.ranges.
    reward if it helps
    SR

  • Cfloop query only finding one record

    I can't figure this out. My query is only finding one record
    (in certain instances), but there are more records in the table. It
    seems to the the problem when I use "LIKE". Everything prints fine
    if I use equals.
    Here's my code:
    <cfparam name="form.kword" default="">
    <cfparam name="form.fyear" default="2008">
    <cfparam name="form.fnum" default="">
    <cfparam name="form.titlew" default="">
    <cfparam name="form.doctrak" default="">
    <cfparam name="url.sterm" default="">
    <cfparam name="url.fyear" default="">
    <cfparam name="url.qtype" default="">
    <!---Queries--->
    <!---From FORM Query the forms table--->
    <cfquery name="displayformresults"
    datasource="#mydatasource#">
    SELECT fstrkeywords, fstrdoctrak, fstrformnum, fstryear,
    fstrtitle, fstrfilesize, fstrfiletype, fdtmrevdt, fblnfillin,
    fstraddendum
    FROM tblext_forms
    WHERE fstrkeywords LIKE '%#form.kword#%' AND fstryear =
    '#form.fyear#' AND fstrformnum LIKE '%#form.fnum#%' AND fstrtitle
    LIKE '%#form.titlew#%' AND fstrdoctrak LIKE '%#form.doctrak#%'
    ORDER BY fstrtitle, fstryear ASC
    </cfquery>
    <cfdump VAR="#displayformresults#">

    <!---Variable anyyeardisplay has been declared within a
    <cfif> tag so where the necessary condition is not met it
    means it would not been declared yet before you ask ColdFusion to
    output it on the table... trouble!
    So amend as below. If for any reason you need to put variable
    nicefdtmrevdt within a conditional statement as well, just do the
    same (as shown) --->
    <cfloop query="displayformresults">
    <cfif "#displayformresults.fstryear#" IS "">
    <cfset #displayformsesults.fstryear# = "2008">
    <cfelse>
    <cfset anyyeardisplay = #displayformresults.fstryear#>
    </cfif>
    <cfset nicefdtmrevdt =
    #DateFormat(#displayformresults.fdtmrevdt#, "mm-dd-yyyy")#>
    <cfoutput>
    <tr>
    <td
    class="fifteen">#displayformresults.fstrformnum#</td>
    <td class="fifteen"><cfif isDefined
    ("anyyeardisplay")>
    #anyyeardisplay#
    </cfif></td>
    <td class="fortyfive"><a href=""
    title="#displayformresults.fstrdoctrak#">#displayformresults.fstrtitle#</a></td>
    <td class="twentyfive"><cfif isDefined
    ("nicefdtmrevdt")>
    #nicefdtmrevdt#
    </cfif>
    <br />
    (#displayformresults.fstrfiletype#,
    #displayformresults.fstrfilesize#)</td>
    </tr>
    </cfoutput>

  • 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.

  • Report / Query to show all texts within all customer master records

    Hi,
    Can anyone let me know if there is a report or a query to show all texts within all customer master records?
    Many Thanks
    Aries

    Hello Aries,
    I don't believe there is a standard SAP report that does this. 
    But,...
    You can see all the customer text types (Customer SD) using transaction VOTX. 
    Table TTXID contains the same info using Text Object "KNVV". 
    If you decide to have a custom ABAP developed use function READ_TEXT.  SE37 can be used to validate a test.
    Regards,
    Jim

  • How do I find who created a particular material master record?

    How can I find who created a material master record when it was created?  I've looked in the item changes log and all it shows is changes, not when the material was created.
    Thanks!

    Hi,
    You can use SE16 + MARA. Field ERSDA will show you the desired date.
    In MM03 there's an icon: white 'i', background blue. Please click on it.
    BR
    Csaba

  • Delete the parent records and child table records at a time

    hi all;
    I am facing the pbm like to delete the all records in child table and corresponding records in parent table at a time. so I want to delete the all the records in child table and corresponding parent records in parent table by using single SQL query. plz help me
    Thanks in advance

    You want to use one single SQL statement to delete the child records in a table and the corresponding master records in the master table??
    That's not quite possible with a single SQL, of course unless you are talking about Oracle Forms, where you have a relation and set the delete behavior to Cascading, like said in the above posts.
    Tony

  • How to insert record in child table with foreign key

    Hi,
    I am using Jdeveloper 11.1.2.0. I have two master table one child table.
    How to insert and update a record in child table with foreign key ?
    I have created VO based on three EO(one eo is updatable other two eo are references) by using joined query.
    Thanks in Advance
    Edited by: 890233 on Dec 24, 2011 10:40 PM

    ... And here is the example to insert using sequenceimpl by getting the primary key of the master record and insert master and detail together.
    Re: Unable to insert a new row with a sequence generated column id
    -Arun

  • Unable to insert record in child block

    Dear all,
    I am facing a very strange problem.
    Actually i have a master-detail form where i need to insert master record as well as child records for the corresponding master item.
    For this i have a LOV in master block which populate the master item and execute the coresponding child records.
    so first time when i load the form i select a item from master block through a LOV this time :SYSTEM.BLOCK_STATUS is NEW and i populate a item from LOV then :SYSTEM.BLOCK_STATUS is NEW changed to query and i have inserted a next record in child block pressed F10 and it saved very well.
    But the problem is when i again select another item from master block through LOV and again tried to insert a record in child record this time it won't saved and the very stragly the cusor moved to master item showing the FRM-40600'Record has already been inserted'
    Please help why is it happening ?
    Need yours help.

    But the problem is when i again select another item from master block through LOV and again tried to insert a record in child record this time it won't saved and the very stragly the cusor moved to master item showing the FRM-40600'Record has already been inserted'When you select a new record in the Master block through the LOV, make sure you clear your form before you query the selected record. Forms thinks you are modifying the same master record and not a new record.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Some record doesnt load

    hi all
    some record in my select query in crystal report doesnt load!
    I select from 2 table,the first table values load successfuly but the secound table values doenst load and the records is empty.
    the tables have a relationship between id field.
    this is my select query:
    select * from pro inner join fac on pro.id=fac.id where fac.id=2 and pro.id=2
    I have 2 table: fac and pro,fac is the parent table and pro is the child.
    look at this picture:
    http://s1.picofile.com/file/6516165990/23423.jpg
    id and date from fac table loaded and info,total,price doent load.but there is 4 empty record from secound table.
    thanks

    I used this codes :
    da.SelectCommand.CommandText = "select pro.ci,pro.ct,pro.cp,fac.da,fac.id,fac.tp from pro inner join fac on pro.id=fac.id where fac.id=2 and pro.id=2";
                DataSet ds = new DataSet();
                da.Fill(ds, "pro");
                da.Fill(ds, "fac");
                con2.Close();
                rd.Database.Tables[0].SetDataSource(ds.Tables[0]);
                rd.Database.Tables[1].SetDataSource(ds.Tables[1]);
                this.crystalReportViewer1.ReportSource = rd;
    for load multi tablse in one dataset for crystal report.
    the values loaded but each record has load four times.
    where is the problem?:(

  • User Master Record : Which table the Email Id stored?

    Hi All,
    Which table and what is the field the Email id stored in.
    I checked the USR02 and some other tables and I did't find it.
    Thanks.
    Rgds,
    Raj.

    >
    John Navarro wrote:
    > I run into to this problem many moons ago and the solution is to run tcode SQVI.
    >
    > Create a query and join the following tables (USR21 & ADR6) and use the relevant fields.  I have the complete steps documented in a procedure if you need it posted on this thread.
    >
    > Let me know and good luck!
    OK - Here it is!  I forgot I got the step by step procedure on this forum
    You can get the information through one more option also. In case of function module you need to execute the module again and again for each user or may be need to write a report. I would like to suggest you an alternative. That is making use of queries.
    1. Go to transaction SQVI.
    2. In the input field Quick View give the any name for query for example Z_EMAIL_ADD.
    3. Choose create option. In the resulting pop up give description in Title field. In data source choose TABLE JOIN. Select Basis mode.
    4. In the next screen choose INSERT TABLE pushbutton and in the pop up give USR21. Then again choose INSERT TABLE pushbutton and this time give ADR6.
    5. Now go back using back arrow or F3.
    6. Now in the new screen you will be under the tab strip List fld select.. From that entries under available filed (on right hand side) select User name in user master record and the first entry for Internet mail (SMTP) address. Now using single arrow pushbutton pointing towards left move these fields to tabstrip List fld select.
    7. Now go to tabstrip selection filed. As done in step 6 move User name in user master record under it.
    8. Save the changes and go back. A pop up will come asking you to save quick view Z_EMAIL_ADD. Choose yes.
    9. Now execute the query. In the input field you can give one user or multiple users at a given time.
    This approach is easier and time saving in my opinion and gives output in desirable format.
    Regards,
    -John N.

  • FRM-40350: Query caused no records to be retrieved

    hi
    apps--12.0.6 os--IBM AIX on POWER Systems (64-bit)
    When trying to find service request (e.g. 33599) throws a FORMS note: “FRM-40350: Query caused no records to be retrieved”. This is happening in FORMS.
    Regards

    When trying to find service request (e.g. 33599) throws a FORMS note: “FRM-40350: Query caused no records to be retrieved”. This is happening in FORMS.Some Service Requests Are Not Accessable - Error FRM-40350 [ID 602803.1]
    Service Requests Cannot Be Retrieved When Using Folders - Error FRM-40350 [ID 744321.1]
    How To Research An Item That Errors FRM-40350 And Cannot Be Queried In The Master Or Organization Items Form [ID 413104.1
    Unable To Access Upgraded Service Request In the CSXSRISR Form [ID 462543.1]
    R12: Cost Management Drilldown Throws ORA-01403: No data found [ID 782062.1]
    FRM-92100 Error in The Workbench Tab After Find For A Service Request [ID 458115.1]
    "Frm-40301: Query Caused No Records To Be Retrieved. Re-Enter" While Querying Some SRs In Create Service Request Form [ID 1324909.1]
    Thanks,
    Hussein

  • Customer Master Record and Sales Area

    Hi All,
    I'm new to SAP SD and so would appreciate some help.
    A Customer Master Record may exist for many sales areas.  Does this mean many sales area within one Sales Organizational right??

    Welcome to the forum.  As a new member, I would like to inform you that there are certain rules and regulations applicable to this forum which you can find to your right screen where it has also been indicated that posting basic / repeated query is not allowed.
    Please AVIOD  posting queries like this.  Since you have indicated that you are new to SD, it would be better if you test in SAP and see whether system is allowing or not so that you will learn on your own. 
    G. Lakshmipathi

Maybe you are looking for

  • PK with TIMESTAMP causes insert unique constraint error at DST switch

    Hi, I have a test that inserts rows in a table that has a TIMESTAMP in its PK. When inserting rows that cross over the November DST change, it tries to insert these dates: --- Sun Nov 02 02:00:00 EST 2008 --- Sun Nov 02 01:00:00 EST 2008 --- Sun Nov

  • Server on isolated network

    Question is: what's a good configuration for multiple ethernet ports, i.e. four in a Mac Pro, with OS X Server with Open Directory that does not cause the Open Directory pane of Server Admin to hang eventually. I was using three ports for my cluster:

  • How can I add the cc line to my emails from iphoto

    I want to use the email in my iphoto program to email an invitation to a large group of people, but how do I add the cc line in my header of the email?

  • How to send a Control or frame Back(send to back)

    Hi all , I have a Graphic Frame I want to sent this control back i.e implementing "Send to Back". How to do it progammatically from my plugin

  • Just tell us how to get rid of Firefox and return to IE

    I want to un-install Firefox and return to IE. DO NOT LIKE FIREFOX! DON"T WANT TO FIX IT! I just want to get rid of it and be done with it! Do not want to have to re-format and re-install everything but if that's what it takes I will do it!