Extract First Matchin Record

Hi,
This is my first post to this forum. I need some help in writting a bit complex query. there are two tables. which have 1-m relationship. for each record in table a i want to extract the first matching row from table b.in table b there are many matches but i want to extract the first match and ignore the rest for each value of the primary key in table A.
Table A
field1 field2
1 one
2 two
3 three
Table B
fieldb1 fieldb2 fieldb3
1 one 55
1 one 66
1 two 77
I want join on field1 and fieldb1 than check for condition where fieldb2 = one and fieldb3>0.so in this case it will return 2 records. but i want only the first match that is one 55.
Thanks in advance.
Raj.

Hi,
The query you posted:
SELECT ll1.ln_id,min(princ_apld_amt), ll1.crtlamt_apld_amt, ll1.actl_1001pct_upb_amt
FROM ll_ln_actvy00_1 ll1, ll_ln_actvy00_2 ll2
WHERE ll1.ln_id = ll2.ln_id
AND ll2.princ_apld_amt < ll1.crtlamt_apld_amt
group by ll1.ln_idis not what you're actually running.
The query above will cause the error "ORA-00979: not a GROUP BY" expression because there are columns in the SELECT clause ( ll1.crtlamt_apld_amt and ll1.actl_1001pct_upb_amt) that are not in the GROUP BY clause.
What is the data in your tables that is producing the output you posted? Forgive me if you already posted it, but the only sample data I found is in your very first message, and I don't see how this output comes from that data. (Though it is a long thread, and I may have missed something.)

Similar Messages

  • Extracting Multiple Logical Records through sql loader

    Hello gurus,
    I have few questions regarding the sql loader. I m totally new to this i have never used, this is the first time i m using
    1.
    How do i find the position number of the charcter or a number ? do i need to physically count the position ? is ther any specific way of counting or use textpad to do that ?
    I know it sounds like silly question... but i wanted to know if there is any better way of doing it
    2.
    example data
    1119 Smith      1120 Yvonne
    1121 Albert     1130 Thomas
    The following control file extracts the logical records:
    INTO TABLE emp
         (empno POSITION(1:4)  INTEGER EXTERNAL,
          ename POSITION(6:15) CHAR)
    INTO TABLE emp
         (empno POSITION(17:20) INTEGER EXTERNAL,
          ename POSITION(21:30) CHAR)---
    2. Can you please expalin me what does the "null if deptno = blanks " ?
    deptno POSITION(1:2)  INTEGER EXTERNAL(2)
                  NULLIF deptno=BLANKS,I really appriciate it ~
    Thanks

    Hi,
    The NULLIF means load blanks as NULL
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#sthref1129
    Not sure I understand your first question. You must of course know the format of the file, TextPad could be an ok tool for determining that format for a fixed column width file.
    Regards
    Peter

  • How to get first 10 records from the database using JSP

    i want ot get first 10 records from the database and then after clicking the next button in the page,it must show the next precceding 10 records from the database.i am getting the first 10 records .but how to post to the same page to get another preceeding 10 record.

    Search the forums - this has been asked a lot. I usually recommend experimenting with tops and order bys until you're satisfied.
    Kind regards,
      Levi

  • Need Help in Inserting first ever record

    I need help in inserting my first ever record from an OAF page.
    I've created an AM 'MasterAM', added 'MasterVO' to it. Created a Page CreatePG which has a submit button, id = Apply
    Below is processRequest of CreateCo
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (!pageContext.isFormSubmission()) {
    am.invokeMethod("createRecord", null);
    and below is processFormRequest
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (pageContext.getParameter("Apply") != null)
    OAViewObject vo = (OAViewObject)am.findViewObject("MasterVO1");
    am.invokeMethod("apply");
    pageContext.forwardImmediately("OA.jsp?page=/abcd/oracle/apps/per/selfservice/xxdemo/webui/CreatePG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    Below are 'createRecord' and 'apply' in MasterAMImpl
    public void createRecord(){
    OAViewObject vo = (OAViewObject)getMasterVO1();
    if (!vo.isPreparedForExecution()) {
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    public void apply() {
    getTransaction().commit();
    When I run the page, it opens and I try to enter some data and press Apply. it does not insert into the table.
    Could anyone help me out.
    My jdeveloper version is 10.1.3.3.0.3

    I am facing the same issue.
    rows get inserted into the tbale, but only whol columns have the data.
    all the attributes are correctly mapped to view instance and view attribute.
    My VO has 1 EO and , i have joined another table to get desctriptions of the field.
    could that be the problem ?
    ex :
    select item , desc
    from t , master
    where t.cola=master.colb
    table t is the custom table I want the data to go in. but only who columns appear after commiting.
    any clues ?

  • First Row Record is not inserted from CSV file while bulk insert in sql server

    Hi Everyone,
    I have a csv file that needs to be inserted in sql server. The csv file will be format will be like below.
    1,Mr,"x,y",4
    2,Mr,"a,b",5
    3,Ms,"v,b",6
    While Bulk insert it coniders the 2nd column as two values (comma separte) and makes two entries .So i used filelterminator.xml.  
    Now, the fields are entered into the column correctly. But now the problem is, the first row of the csv file is not reading in sql server. when i removed the  terminator,  i can get the all records. But i must use the above code terminator. If
    am using means, am not getting the first row record.
    Please suggests me some solution.
    Thanks,
    Selvam

    Hi,
    I have a csv file (comma(,) delimited) like this which is to be insert to sql server. The format of the file when open in notepad like below:
    Id,FirstName,LastName,FullName,Gender
    1,xx,yy,"xx,yy",M
    2,zz,cc,"zz,cc",F
    3,aa,vv,"aa,vv",F
    The below is the bulk insert query which is used for insert above records,
    EXEC(BULK INSERT EmployeeData FROM '''+@FilePath+'''WITH
    (formatfile=''d:\FieldTerminator.xml'',
    ROWTERMINATOR=''\n'',
    FIRSTROW=2)'
    Here, I have used format file for the "Fullname" which has comma(,) within the field. The format file is:
    The problem is , it skip the first record (1,xx,yy,"xx,yy",M) when i use the format file. When i remove the format file from the query, it takes all the records but the "fullName" field makes the problem because of comma(,) within the
    field. So i must use the format file to handle this. So please suggest me , why the first record skipped always when i use the above format file.
    If i give the "FirstRow=1" in bulk insert, it shows the "String or binary data would be truncated.
    The statement has been terminated." error. I have checked the datatype length.
    Please update me the solution.
    Regards,
    Selvam. M

  • Extracting purchasing info records

    Hi all,
    I am extracting purch info records and using SE16 and tables EINA and EINE to include plant, info record, material and vendor. I also need to include price of material. any ideas on what table to use for this?
    Thanks in advance.

    Hi,
    Goto se16n, give table EINA, deselect all the fields, select only Inforecord, Material & vendor. Execute and export the file to excel sheet.
    Then in se16n again give table EINE, deselect all the fields, select inforecod, plant & netvalue. Fill the inforecord field with the datas in excel sheet and execute.
    You can get the equired report.
    Reards,
    Prabu

  • How to fetch first 4 records from database.

    hi experts.i am inexperience in this field.
    please tell me suppose i want to extract only 4 records from the database ,
    what is the select statement for this .
    best regards.
    subhasis.

    Hi
    use this program as example.
    u wil get solution.
    REPORT  ZSEN_ABAP_TABLE                         .
    Tables : mara.
    data : wa_mara type mara,
           it_mara type table of mara.
    SELECT * UP TO 4 ROWS FROM MARA INTO TABLE it_mara.
    loop at it_mara into wa_mara.
    Write : / wa_mara-MATNR,
             wa_mara-MTART,
             wa_mara-BISMT.
    endloop.
    Thanks
    Senthil

  • Dynamic load Advance Datagrid for First 10 Record

    Hi
    I have a Advance Datagrid and i have to display the datas of first 10 records in the Grid and then to display the next 10 Records when i scroll the Datagrid
    Can Any one help me in this to Complete the task
    With Regards
    Gopinath.A
    Software Engineer,
    First Internet Systems Pvt Ltd.,
    Chennai.
    India

    Hi danny,
    Thanks for Your Reply...
    I have implemented the same.But i cant get the result..Can u Please send me any Example Regarding it
    With Regards.
    Gopinath.A
    Software Engineer.
    First Intenet Systems.
    Chennai.

  • Extract purchasing info records

    Hi experts,
    Please could you tell me the process to extract purchasing info records for a plant. they need to do a mass update.
    Thanks in advance.

    hi,
    check table EINA, A017 in SE16 tcode...and can mass update frm MEMASSIN...
    Regards
    Priyanka.P

  • First Populated Record

    Hi All,
    is it possible to loop through a field until it finds the first populated record and display it.  The section that i'm using is Report Header.
    Thanks,
    Dave.

    In order to determine the first populated record you'll need a date field to measure when the transaction was recorded.
    If that is the case, you can insert a group on record field and then on date field.  Ensure the date field is set for each day in ascending order.  The first record would be the first on your list.
    I hope that works.
    Regards,
    Zack H.

  • First WBS Record in Project

    I got all wbs record from P6 for specific project except
    first wbs record
    I found in Primavera
    Integraation API that for WBSObject of project it does not
    allow to load that wbs record? How to get first wbs record
    for Project in P6?I am tried load it may way like using
    Primavera Integration API classes like Enterprise laod
    manager,Project contains method LoadAllWBS which are not
    loading WBS record. How should I get First Wbs record for
    specific project?

    Hello,
    Your question would be
    answered best by our Support Team. Support can be
    accessed at
    http://primavera.com/customer/support.asp<br
    />
    Have a great day,
    Justin

  • Extract First letter from each word

    Hi All,
    I have a requirement to extract first letter of each word as shown in below example
    input: abcd output: a
    input: abcd efgh output: ae
    input: abcd efgh ijkl output: aejany help will be highly appreciated
    I am on db version 11g

    jeneesh wrote:
    Just a note - This will not take care of spaces at the end of the line..You're right, and not just spaces but any non-word characters. Here is fixed solution:
    with t as (
               select 'abcd ' str from dual union all
               select 'abcd efgh.' from dual union all
               select 'abcd efgh ijkl,' from dual union all
               select ' a abcd efgh ijkl! ' from dual
    select  str,
            '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
      from  t
    STR                 INITIALS
    abcd                [a]
    abcd efgh.          [ae]
    abcd efgh ijkl,     [aei]
    a abcd efgh ijkl!  [aaei]
    SQL> BTW, oldie_63's solution takes care of spaces but not:
    with t as (
               select ' abcd' str from dual union all
               select '.abcd efgh' from dual union all
               select ',abcd efgh ijkl' from dual union all
               select '! a abcd efgh ijkl' from dual
    select  str,
            '[' || trim(regexp_replace(str,'(\S)\S*\s*','\1')) || ']' initials
      from  t
    STR                INITIALS
    abcd              [a]
    .abcd efgh         [.e]
    ,abcd efgh ijkl    [,ei]
    ! a abcd efgh ijkl [!aaei]
    SQL> Also, OP needs to clarify what to do with hyphenated words:
    SQL> with t as (
      2             select 'sugar-free' str from dual
      3            )
      4  select  str,
      5          '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
      6    from  t
      7  /
    STR        INITIALS
    sugar-free [sf]
    SQL> with t as (
      2             select 'sugar-free' str from dual
      3            )
      4  select  str,
      5          '[' || trim(regexp_replace(str,'(\S)\S*\s*','\1')) || ']' initials
      6    from  t
      7  /
    STR        INITIALS
    sugar-free [s]
    SQL>Or words like:
    SQL> with t as (
      2             select 'O''Reily' str from dual
      3            )
      4  select  str,
      5          '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
      6    from  t
      7  /
    STR     INITIALS
    O'Reily [OR]
    SQL> with t as (
      2             select 'O''Reily' str from dual
      3            )
      4  select  str,
      5          '[' || regexp_replace(str,'\W*(\w)(\w*)|(\W*$)','\1') || ']' initials
      6    from  t
      7  /
    STR     INITIALS
    O'Reily [OR]
    SQL> SY.

  • Display  lines first 10 records field1 next 10 records field2

    HI
      i have an issue in oracle reports.
    i need to display the first 10 records in field1  next 10 record  field2
    please give me a idea my mail id is [email protected]
    Regards,
    Kamaraj

    In OBIEE 10g, within the 'table view properties' options (second icon from left in the edit table screen) you will see an option for rows per page. Set this to 10 and the arrows should appear.
    It can be quite hard to find the screen in question. From the pivot table builder screen, click the big round icon to the left of 'compound layout' drop down. Then you need to click the 'Edit View' icon in the header of the table. Finally you can then click the 'table view properties' icon, second left.
    Good luck,
    Paul

  • Retrieve first 3 records for each id

    Hi there,
    I am having trouble solving this problem. Appreciate for any help.
    tableA
    pidm
    1125
    0034
    tableB
    pidm     term
    1125     2006
    1125     2007
    1125     2009
    1125     2010
    0034 2004
    0034     2006
    0034     2007
    0034 2008
    I want to retrieve only the first 3 records from tableB order by term for each pidm that match to pidm of tableA
    select pidm, term from tableB where pidm in (select pidm from tableA) and rownum < 4
    This only return 3 records instead of 6:
    it should return:
    pidm:     term:
    1125     2006
    1125     2007
    1125     2009
    0034 2004
    0034     2006
    0034     2007
    Thanks

    sql>select pidm, term
      2    from (select a.pidm, b.term, row_number() over (partition by a.pidm order by b.term) rn
      3            from tablea a, tableb b
      4           where b.pidm = a.pidm)
      5   where rn <= 3;
    PIDM TERM
    0034 2004
    0034 2006
    0034 2007
    1125 2006
    1125 2007
    1125 2009
    6 rows selected.

  • Want to get sum/avg first 90% records  in each grouped record set.

    Hi Gurus,
    Need your help or example query which help me to achieve sum/avg first 90% records in each grouped record set. Let me show you the basic query and output and proposed output.
    select Pid, Sum(SalesAmt) TotalSaleAmt, Avg(SalesAmt) AvgSaleAmt, count(*) NoOfSales from ProductSales group by Pid;
    PID TotalSaleAmt AvgSaleAmt NoOfSales
    1 12000 100 120
    2 24000 50 480
    Now I need for PID =1 TotalSaleAmt of first 90% of NoOfSale i.e.120(this is basically nuber of rows found in PrdocutSales Table).
    I hope I am clear enough explain my requirement... I would appreciate if we have some Analytical function available..
    Gurus Pls help me asap..
    Thanks In adavance...
    Srichan.

    Now I need for PID =1 TotalSaleAmt of first 90% of NoOfSale i.e.120(this is basically nuber of rows found in PrdocutSales Table).
    first 90% should mean first 90% by some order, so in this case, which 108 rows (of the 120) do you want to take into consideration?
    with
    the_sample as
    (select 1 the_pid,10 the_sale,1 the_order from dual union all
    select 1 the_pid,20 the_sale,2 the_order from dual union all
    select 1 the_pid,15 the_sale,3 the_order from dual union all
    select 1 the_pid,12 the_sale,4 the_order from dual union all
    select 1 the_pid,12 the_sale,5 the_order from dual union all
    select 1 the_pid,13 the_sale,6 the_order from dual union all
    select 1 the_pid,19 the_sale,7 the_order from dual union all
    select 1 the_pid,11 the_sale,8 the_order from dual union all
    select 1 the_pid,15 the_sale,9 the_order from dual union all
    select 1 the_pid,12 the_sale,10 the_order from dual union all
    select 2 the_pid,25 the_sale,1 the_order from dual union all
    select 2 the_pid,22 the_sale,2 the_order from dual union all
    select 2 the_pid,22 the_sale,3 the_order from dual union all
    select 2 the_pid,23 the_sale,4 the_order from dual union all
    select 2 the_pid,29 the_sale,5 the_order from dual union all
    select 2 the_pid,21 the_sale,6 the_order from dual union all
    select 2 the_pid,25 the_sale,7 the_order from dual union all
    select 2 the_pid,22 the_sale,8 the_order from dual
    select the_pid,the_sum,the_avg
      from (select the_pid,
                   sum(the_sale) over (partition by the_pid order by the_order) the_sum,
                   round(avg(the_sale) over (partition by the_pid order by the_order),2) the_avg,
                   the_order,
                   floor((0.9 * max(the_order) over (partition by the_pid))) to_pick
              from the_sample
    where the_order = to_pickRegards
    Etbin

Maybe you are looking for

  • "Class can't be instantiated " error message. Help !

    Dear Java People, In trying to do a program that outputs a sound with every button click I have no compilation errors but a runtime error that says: "class can't be instantiated" below is the program and below that the error message thank you in adva

  • I really hate HND program!!!

    I just bought the linksys router N Ultrarange.. well everything works out fine so I liked it.. but!! home network defender blocked every single thing! I can't even go ebay for selling my item!! so how to fix it? if i cant i'll just change to other ro

  • Badi implementation for T-code: QE71

    Hi Experts, I am implementing a badi in transcation QE71 my requirement is to automatically generate quality data. In this t-code we enter the value for the MIC of the material for each inspection lot. But in the screen only one entry can be done at

  • To create resopnsibility in 11.5.5

    Hi, i am new in apps dba area. can somebody please let me know qhat are the minimal things to be consider while creating responsibility in 11.5.5 ? any metalink note ? also let me know what r the mandatory profile options to set. thanks, dbaspps.

  • Webutil in forms 6i

    hi all i am using forms 6i with oracle 8i database. plz tell me that how can i deploy webutil utilities with forms 6i. please tell me in detail how i can deploy it and then how i can use it in my forms 6i. bye thanx in advance:)