How to distinct records?

hi,
i need to distinct records in my query but i don't know how to do that.
i use SQLX functions. this is my query:
select xmlelement ("narqdi",
xmlelement ("order",
(select xmlagg (
xmlconcat (
xmlelement ("nom_order", nor.nom_order),
xmlelement ("nch", nor.chnom1),
xmlelement ("partida",
(select xmlagg (
xmlconcat (
xmlelement ("npartida", nor2.npartida),
xmlelement ("ppnom",
(select xmlagg (xmlelement ("pnom", nor3.pnom))
from narqd_order nor3
where nor3.nom_order = nor2.nom_order
and nor3.npartida = nor2.npartida
from narqd_order nor2
where nor2.nom_order = nor.nom_order
from narqd_order nor
where nor.NOM_ORDER = '5970'
from dual
i have 18 records in table for record nom_order = '5970' and i receive 18 tags <partida> and 18 tags for each ppnom :(
please help me.
i tried to put distinct in every select but this is no reason.
i tried to put agregate function in each select statement but in select for <pnom> it does not work...
best regards
Message was edited by:
Fitibaldi
Message was edited by:
Fitibaldi

Arti,
Here's another solution (that will still use locking, and can help avoid the "lost update" problem):
http://stegemanoracle.blogspot.com/2006/03/using-updatable-views-with-adf.html
John

Similar Messages

  • How can I get the number of distinct records that each field of a DB table has?

    Hi everyone,
    I would like to know how to get he number of distinct records that each field of a DB table has. When tracing a SQL statement either in ST12 or ST05, in the plan execution, if the sentence made useage of an index, then I can click in the index name and see this kind of information (no. of distinct values for each field of that index).
    Can I do something like this but with the whole fields of a table?
    What I have found until now is in Tx ST10; I search for whatever kind of table statistics and then use the function of "Analyze table" (which takes me to Tx DB05). In here, I can enter a table and up to 5 fields in order to get the information that I want.
    Is there any other way to do this?
    Regards,
    David Reza

    Hi David,
    You can export the same to excel and sort as per requirement.
    Sorry is that what you are looking for ?
    Regards,
    Deepanshu Sharma

  • How  to divide distinct records in a table into batches

    Hi all,
    I need a small help . I have some 3 to 4 lakhs of records in table . I want to divide these records into batches by assigning some batchno to some set of records. i.e i'll query some distinct records those distinct records should be assigned to one batchno . i.e when i query there may be some 100 records of one unique value in a column and 1000 next and so on . I want to make these records to one one batchno . Can any one help in this regard.
    Regards,
    rakesh

    May below given SQL help you...
    WITH T AS
    SELECT 'A' COL1 FROM DUAL UNION ALL
    SELECT 'B' COL1 FROM DUAL UNION ALL
    SELECT 'D' COL1 FROM DUAL UNION ALL
    SELECT 'A' COL1 FROM DUAL UNION ALL
    SELECT 'X' COL1 FROM DUAL UNION ALL
    SELECT 'P' COL1 FROM DUAL UNION ALL
    SELECT 'B' COL1 FROM DUAL
    SELECT COL1 , 'BTCH_'||DENSE_RANK() OVER (ORDER BY COL1) BATCH_NO
    FROM   T;
    COL1     BATCH_NO
    A     BTCH_1
    A     BTCH_1
    B     BTCH_2
    B     BTCH_2
    D     BTCH_3
    P     BTCH_4
    X     BTCH_5
    7 rows returned in 0.00 seconds     *009*

  • Select distinct records in Mapping with no Key field (all fields can vary)

    Hi Experts,
    Let me take an example (not the actual requirement but same scenario) to explain the problem where I need your help to get best possible way to resolve. This has to be achieved in mapping, don't have other options as its part of complex end 2 end scenario.
    I have following input XML:
    <Employee>
       <Details>
          <Id>123</Id>
          <Name>ABC</Name>
         <Role>Manager</Role>
          <Area>Bangalore</Area>
        </Details>
        <Details>
           <Id>123</Id>
           <Name>ABC</Name>
            <Role>Manager</Role>
             <Area>Pune</Area>
         </Details>
          <Details>
           <Id>123</Id>
           <Name>ABC</Name>
            <Role>Advisor</Role>
             <Area>Bangalore</Area>
         </Details>
          <Details>
           <Id>123</Id>
           <Name>ABC</Name>
            <Role>Manager</Role>
             <Area>Bangalore</Area>
           <Details>
           <Id>143</Id>
           <Name>ABC</Name>
            <Role>Manager</Role>
             <Area>Bangalore</Area>
         </Details>
    </Employee>
    The output XML is:
    <Employee>
       <MainRec>
           <Id>123</Id>
            <Name>ABC</Name>
             <table name = 'Roles'>
                   <record>
                          <Id>123</Id>
                           <Role>Manager</Role>
                            <Area>Bangalore</Area>
                      </record>
                      <record>
                          <Id>123</Id>
                           <Role>Manager</Role>
                            <Area>Pune</Area>
                      </record>
                      <record>
                          <Id>123</Id>
                           <Role>Advisor</Role>
                            <Area>Bangalore</Area>
                      </record>
                  </table>
          </MainRec>
          <MainRec>
            <Id>123</Id>
            <Name>ABC</Name>
             <table name = 'Roles'>
                   <record>
                          <Id>143</Id>
                           <Role>Manager</Role>
                            <Area>Bangalore</Area>
                      </record>
                </table>
            </MainRec>
    </Employee>
    As you can see from the example above, here I want to populate only distinct records under table, but there is no key fiield to ditunguish. Any of the 3 fields (Id, Role,Area) can vary and between 2 records if all of these fields are same then its duplicate else select it. So in above XML just discard the 4th record from the source XML and populate all others. Each record has to be checked against all other records all 3 values (ID, Role, Area). Only when none of the records have exactly the same values, populate it.
    Also records with different ID come under different table node. Hope my requirement is clear, if not please let me know, i will try to explain better.
    I thought of creating a UDF to achieve this but not able to decide how to match it to the output message here.
    Best Regards,
    Pratik

    Hi,
    For the main record, I think you only need to check for each unique ID, e.g
    Id --> removeContext --> sort:ascending --> splitByValue:valueChanged --> collapseContext --> MainRec
    For the record, however, you need to create a UDF that will filter out the duplicate values. For this, the UDF sample mentioned here contained multipleResult lists
    Id --> removeContext --> concat: : --> concat: : --> UDF --> splitByValue:ValueChanged --> record
    role --> removeContext --> /          /                \ --> Id
    area --> removContext -------------> /                  \ --> role
                                                             \ --> area
    Context type UDF
    Arguments: input
    Result: IdResult
    Result: roleResult
    Result: areaResult
    Vector temp = new Vector();
    for(int a=0;a<input.length;a++){
       if(!temp.contains(input[a])
             temp.add(input[a]);
    for(int a=0;a<temp.size();a++){
       String tmp = (String) temp.get(a);
       /*split according to field */
       IdResult.addValue(tmp.substring(0,tmp.indexOf(":")));
       roleResult.addValue(tmp.substring(tmp.indexOf(":")+1,tmp.lastIndexOf(":")));
       areaResult.addValue(tmp.substring(tmp.lastIndexOf(":")+1,tmp.length()));
    note: Id and record will both be using the IdResult list.
    Hope this helps,
    Mark

  • "Select Distinct Records" Option Not Available

    Hello Experts.
    I am working on a new report in CR XI, and noticed that I had many duplicate records.  I went to the File; Report Options; and expected to click on "Select Distinct Records", but that choice was grayed-out.  What would have caused me to lose this option, and how do I fix it?
    Thanks in advance for your help.

    Not sure if this covers it or not, but....
    The Select Distinct Records command is only available for ODBC, OLE DB, and SQL native drivers; it is not available for Stored Procedures. Note also that your server may automatically sort returned values if no sort is specified in Crystal Reports.

  • Distinct records

    hi all,
    i am calculating sum for one column but i want sum for the distinct records from the table
    SELECT D_NUMBER,D_TYPE,SUM(D_AMT)
    FROM D_TABLE
    WHERE D_CODE =:PARAMETER
    GROUP BY D_NUMBER,D_TYPEin the above case D_NUMBER,D_TYPE may repeat i want the amount for distinct records. how can i for a query to get (tried with distinct but not getting the correct sum..
    Thanks..

    Hi,
    so you searching for something between d_number,d_type and d_amt and the sum of d_amt based on the first two. Then you need a differentiator, how do you do make the first 2 distinct based on some other column, so these 3 will be distinct, otherwise it will not be possible, except if you say the first 3 rows belong together, and that is what I want to be summed.
    Herald ten Dam
    htendam.wordpress.com

  • Distinct records with conditional select formula

    Post Author: nelsonchris
    CA Forum: Data Connectivity and SQL
    Hello,
    I have a simple report pulling data from two tables. I want
    only distinct records. I am selecting records based on
    parameters; here is the select formula:
    ({?Service Name} = "*" or {selsvc.ServiceName} like
    {?Service Name})and
    ({?Program Name} = "*" or {selsvc.Selected Service Entry 
    Program Name} like {?Program Name}) and
    ({?Agency Name}  = "*" or {selsvc.Selected Service Entry 
    Agency Name} like {?Agency Name})
    The problem comes from the fact that Crystal will add the
    selsvc fields to the reports SQL select code, which has the
    effect of duplicating some records that do not have the same
    values for the selsvc fields. The select formula above is
    the only place in the report where values from the selsvc
    field are used, and as you can see they are only used when
    the user has submitted a matching parameter for them. I can
    not figure out how to get rid of the duplicates, please
    help!
    Thanks for your time,
    Chris

    Post Author: yangster
    CA Forum: Data Connectivity and SQL
    I don't follow why you are getting duplicates with your selectionare you getting duplicates without the selection criteria?if you are then they really are not duplicates and there could be issues with your joins between the 2 tables

  • Distinct Records Selection in Crystal 11

    Need to select Distinct Records only, but the drop down under 'Database' shows the 'Select Distinct Records' option grayed out.  Why does Crystal do that, and how may I eliminate duplicate records?  Thanks!

    Hi Brian,
    This issue normally comes when there are multiple datasources being used. For example if you are using two databases, like Oracle and MS Access to fetch data, the "Select Dictinct Records" will be greyed out.
    In this case, you might want to write a query in the Add Command option which select distinct records.
    If you are using only one database, then check if you are able to select "Select Dinstinct Records" in the Database menu.
    Please let us know if this helps.
    Regards,
    Abhishek.

  • Get Distinct records with a condition

    I have a table with multiple records per Person and an active status column. I would like to fetch distinct records by PersonID and PersonName but also return active status with a condition that if person is active on at least one he is considered active.
    Here is my table.
    DECLARE @Person TABLE (PersonID INT, PersonName VARCHAR(50), DeptName VARCHAR(50), Active bit)
    INSERT INTO @Person (PersonID, PersonName, DeptName, Active) VALUES (111, 'John', 'Finance', 0), (111, 'John', 'HR', 1),(222, 'Jack', 'Payroll', 0),(333, 'Mark', 'Facilities', 1),(444, 'Bill', 'IT', 0),(444, 'Bill', 'HR', 1),(444, 'Bill', 'Finance', 1)
    My resultset after the query should be as follows.
    (111, 'John', 1),(222,'Jack',0),(333,'Mark',1),(444,'Bill',1)
    Thanks for the help.

    >> I have a table with multiple records [sic] per Person and an active status column. <<
    Rows are not records. Tables have to have a key by definition and since they model a set, the names are plural or collective. These are fundamentals that were covered in the first few chapters of any book on RDBMS. You do not know ISO-11179 naming rules. 
    You still use assembly language bit flags in SQL! A status is a state of being so it requires a temporal component. Do you really know people with FIFTY character name? Even in Poland and India, that is not likely. But when you allow garbage data, you will
    get it. 
    Identifiers are CHAR(n), not numeric; what math do you do with them? Again, this is a fundamental of data modeling. 
    You are simply reenforcing your bad habits and not taking the time to learn how to do RDBMS correctly. 
    CREATE TABLE Personnel --- collective name!
    (person_id CHAR(3) NOT NULL,
     person_name VARCHAR(10) NOT NULL, 
     dept_name VARCHAR(10)NOT NULL, 
     hire_date DATE NOT NULL,
     termination_date DATE,
     CHECK (hire_date < termination_date),
     PRIMARY KEY (person_id, hire_date));  -- null means current.
    See how a valid design makes finding a status possible? And it shows us just what a mess you have! Bill is working in TWO departments! See how the key prevents this error? We should add more constraints, but I do not think you are ready for that yet. 
    SELECT person_id, person_name, dept_name AS current_dept_name
      FROM Personnel 
     WHERE termination_date IS NULL;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to lock record in a remote database ???

    Hi All!
    How to lock record in a remote table ??? Is it possible to lock by using the RPC ??? What are the options available ??
    thanks
    Sanjeeb Bose
    HCL Infosystems Ltd
    Kolkata India

    DBLinks may be one option...
    --Shirish                                                                                                                                                                                                                       

  • How to add records or how to maintain list in stored Procedure

    Hi,
    I am facing an issue in the addition of record in the type
    create or replace
    TYPE               "PROD_SEARCH_COUNT_TBL"                                          AS TABLE OF PROD_SEARCH_COUNT_OBJ;
    create or replace
    TYPE               "PROD_SEARCH_COUNT_OBJ"                                          AS OBJECT
    ( /* TODO enter attribute and method declarations here */
        V_Name Varchar2(500 Byte),
        v_Value Varchar2(500 Byte),
        v_count Number
    I want to add records to the type I tried following way
    prod_wcf_rec PROD_SEARCH_COUNT_TBL;
      SELECT PROD_SEARCH_COUNT_OBJ('Name1','Value1',1) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
        SELECT PROD_SEARCH_COUNT_OBJ('Name2','Value2',2) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
        SELECT PROD_SEARCH_COUNT_OBJ('Name3','Value3',3) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
        SELECT PROD_SEARCH_COUNT_OBJ('Name4','Value4',4) BULK COLLECT INTO PROD_WCF_REC FROM DUAL;
    DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');
    FOR i in 1 .. prod_wcf_rec.COUNT
    LOOP         
    DBMS_OUTPUT.PUT_LINE (prod_wcf_rec(i).V_Name||' - '||prod_wcf_rec(i).v_Value||' - '||prod_wcf_rec(i).v_count);     
       END LOOP;
       DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');
    In printing I am getting last records only .So is there any way to add records to PROD_SEARCH_COUNT_TBL
    How to add records or how to maintain list in stored Procedure

    Every time you BULK COLLECT into a collection type the value is overwirtten. So you need to try something like this.
    SQL> create or replace type prod_search_count_obj as object(v_name varchar2(500 byte), v_value varchar2(500 byte), v_count number)
      2  /
    Type created.
    SQL> create or replace type prod_search_count_tbl as table of prod_search_count_obj
      2  /
    Type created.
    SQL> declare
      2    prod_wcf_rec prod_search_count_tbl;
      3  begin
      4    select obj_val
      5      bulk collect into prod_wcf_rec
      6      from (
      7            select prod_search_count_obj('name1','value1',1) obj_val from dual
      8            union all
      9            select prod_search_count_obj('name2','value2',2) from dual
    10            union all
    11            select prod_search_count_obj('name3','value3',3) from dual
    12            union all
    13            select prod_search_count_obj('name4','value4',4) from dual
    14           );
    15
    16    dbms_output.put_line ('-----------------------------looping----------------------------');
    17    for i in 1 .. prod_wcf_rec.count
    18    loop
    19      dbms_output.put_line (prod_wcf_rec(i).v_name||' - '||prod_wcf_rec(i).v_value||' - '||prod_wcf_rec(i).v_count);
    20    end loop;
    21    dbms_output.put_line ('-----------------------------looping----------------------------');
    22  end;
    23  /
    -----------------------------looping----------------------------
    name1 - value1 - 1
    name2 - value2 - 2
    name3 - value3 - 3
    name4 - value4 - 4
    -----------------------------looping----------------------------
    PL/SQL procedure successfully completed.
    SQL>

  • How Do I record My Business Skype-to-Phone Calls?

    I've been using 3rd party recording devices for a long time, and suddenly my audio files are just now going crazy. When I try recording we are speaking over each other on the recordings. I've tried downloading almost all the recommended 3rd party recording devices listed here https://support.skype.com/en/faq/FA12395/how-can-i-record-my-skype-calls but nothing is working properly.
    Callnote, MP3 Skype Recorder, iRecorder, iFree Skype Recorder, G-Recorder and a few others are just not working.
    Is anyone successfully recording their audio from skype to phone conversations? Please help. I'm loosing money and need to resolve this immediatly.
    Thank you,
    Ashley

    ashleystamatino wrote:
    I've been using 3rd party recording devices for a long time, and suddenly my audio files are just now going crazy. When I try recording we are speaking over each other on the recordings. I've tried downloading almost all the recommended 3rd party recording devices listed here https://support.skype.com/en/faq/FA12395/how-can-i-record-my-skype-calls but nothing is working properly.
    Callnote, MP3 Skype Recorder, iRecorder, iFree Skype Recorder, G-Recorder and a few others are just not working.
    Is anyone successfully recording their audio from skype to phone conversations? Please help. I'm loosing money and need to resolve this immediatly.
    Thank you,
    Ashley
    Hi Ashley,
    Did you manage to get one that works in the end?

  • I have completed a keynote presentation with music already. How do I record the slideshow so I can burn it to a DVD disc. I have tried to export it as a Quicktime file but the transitions have been slow that the music finishes first.

    How do I record a keynote slideshow with an attached music already? I trid to export it through Quicktime but the final result is different from the original keynote presentation. What I mean is that the slide transitions are slow that the musci finishes first before the slide presentation.

    Keynote: Exporting a presentation from Keynote to iMovie
    http://support.apple.com/kb/HT2655

  • How can I record an audio sound and convert it to a ringtone?

    How can I record an audio sound and convert it to a ringtone?

    Record your voice using iPhone (for ringtone only 35 secs or under are valid), sync iPhone with iTunes.
    In iTunes the recorded voice is listed under Music as some_numbers.m4a.
    Right click on the item and choose Create AAC version.
    Drag the converted voice onto the desktop.
    Delete the voice copy in iTunes. (important step)
    On desktop, rename the some_number.m4a to something_more_intelligent.m4r
    Drag it back to iTunes and you will find it under Tones.
    Now select it (for sync) and connect your iPhone, do a sync.
    If everything works out, it will be in Settings > Sounds > Ringtone.
    Now choose a contact you want to assign this ringtone, tap Edit and add the ringtone.
    Hope this helps.

  • How can I record an audio file directly from a digital recording device directly to the iMac?

    How can I record audio directly to my iMac from a digital recoding device?

    What digital recording device?

Maybe you are looking for

  • After adding folders to iTunes library, now have duplicates of each song

    I store all my music on a separate drive, M:\ I have a specific file structure setup that has worked for me for years, M:\Artist\Album I recently received an iPod for my birthday, and started using iTunes. After adding my music drive (M:\) for inclus

  • How to I set up multiple devices with iMessage so I don't have multiple conversations?

    My family has two iTouchs and 2 iPhones. I have all 4 set up on the same apple ID so when purchases are made from the app store or iTunes then is comes from one account.  The problem I am having is texting. When the iPhones text either of the iPods i

  • Need Help setting up "Network Home Directories" or Something Similar

    Alright so, I am sure the answer to my question exists but I have no idea what i am looking for as far as syntax is concerned. I have taken over as tech at a full mac School and have not touched a mac before in my life. I will try my best to give a d

  • JS CS3: Is a property read only? How to find out...

    Hello all, I found out about the x.reflect.properties object and find it very helpful in my current project. Now I know how to find out about the properties of a dynamically given object :) But here's the rub: is there any better way to find out if I

  • Changing persitence FileI/O to DB2e

    Hi, The persistence of my app was development withFile I/O. Now, we want use DB2e. I would like to know, if it's need just do the download of the ADD-ON for DB2e or it's necessary change something in my persistence? We are using Smart Sync. Thanks. M