Group by result set divergence

Hi all

Please help me on below.

When I group by result set is as below.

SQL > select count (*), the Group of the stg_famis_equip, by attribut2, attribut2 having count (*) > 1;

COUNT (*) ATTRIBUT2

---------- --------------------

2 FM023566                                                            

2 FM021481                                                            

2 FM025833                                                            

2 FM058806                                                            

Where, if I query with WHERE clause for certain values as below.

Please suggest me on, why it is show as count = 2 and when questioning with only WHERE clause (some time no record).  I do one any error... Please suggest me.

SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM023566';

ATTRIBUT2 ATTRIBUT3

--------------------           --------------------

FM023566 12

SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM021481';

ATTRIBUT2 ATTRIBUT3

--------------------           --------------------

FM021481 11

FM021481 12

SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM025833';

ATTRIBUT2 ATTRIBUT3

--------------------           --------------------

FM025833 07

FM025833 12

SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM058806';

no selected line

I'm on the Oracle 11 g Enterprise Edition Release Database 11.2.0.2.0 - 64 bit Production

Thank you

This means that:

FM023566 has the new line and return at the end of the string (13/10)

FM021481 is clean

FM025833 is also clean

FM058806 has the new line and carriage return to then end of the string

Trim will replace spaces when not specified what should be trimmed. If you could do a RTRIM (attribute2, CHR (13): 10 to clean the data.)

HTH

Tags: Database

Similar Questions

  • Combine multiple lines into one line (from two tables / result sets)

    Hello experts,

    I would like to know how to combine multiple lines/records in a single record. Here are the DDL and DML to tables:

    create table test_table)

    client_name varchar2 (50 char),

    login_time timestamp (6).

    logout_time timestamp (6).

    auto_type varchar2 (10 char)

    )

    create table root_table)

    navigation_time timestamp (6).

    client_name varchar2 (50 char),

    VARCHAR2 (50 char) nom_du_groupe

    )

    Insert into test_table

    values ("John", TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    Insert into test_table

    values ('David', TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:14:22.333 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), "David", "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'David', 'GROUP_5');

    game results test_table

    client_name

    login_time logout_time auto_typeJohn05/12/2013 5:04:01.512000 PM05/12/2013 5:27:31.308000 PMSIMPLEDavid05/12/2013 6:33:01.308000 AM05/12/2013 6:45:01.112000 AMSIMPLE

    root_table result set

    navigation_time client_name GroupName
    05/12/2013 5:04:01.512000 PMJohnNot valid
    05/12/2013 5:14:22.333000 PMJohnGROUP_1
    05/12/2013 5:27:31.308000 PMJohnGROUP_1
    05/12/2013 6:33:01.308000 AMDavidNot valid
    05/12/2013 6:45:01.112000 AMDavidGROUP_5

    And here is the SQL code I'm writing:

    Select a.customer_name, a.login_time, a.logout_time, a.auto_type, Max (b.group_name)

    from test_table a, b root_table

    where a.customer_name = b.customer_name

    Group of a.customer_name, a.login_time, a.logout_time, a.auto_type

    As the 'invalid' value is greater than the value "GROUP_1" (based on the number of letter in English), the GroupName is returned as 'invalid '. I want to bring the GroupName based on the navigation_time column in the root_table so that it always returns a valid GroupName. Please help me.

    Output current:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     Not valid

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     Not valid

    Expected results:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

    --------------------------------------------------------------------------------------------------------------------------------------------

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     GROUP_1

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     GROUP_5

    Thank you!

    Adding INSERT statements, current and planned outputs.

    This...

    SELECT client_name

    login_time,

    logout_time,

    auto_type,

    GroupName

    Of

    (select a.customer_name,

    a.login_time,

    a.logout_time,

    a.auto_type,

    b.group_name,

    ROW_NUMBER() over (PARTITION BY a.customer_name, a.login_time, a.logout_time, a.auto_type ORDER BY b.group_name) rn

    from test_table a, b root_table

    where a.customer_name = b.customer_name)

    WHERE rn = 1;

    OUTPUT:-

    =========

    David DECEMBER 5, 13 06.33.01.308000000 AM DECEMBER 5, 13 06.45.01.112000000 AM SIMPLE GROUP_5
    John DECEMBER 5, 13 05.04.01.512000000 PM DECEMBER 5, 13 05.27.31.308000000 PM SIMPLE GROUP_1

    Thank you

    Ann

  • How to add or merge the 2 rows in a result set

    Hi all

    What is the best way to add the 2 rows? I need this results defined below as is except that I need lines with 0-30 activity codes to merge together in the activity of 0 Code. Thus, the hours would be 7466.75. What I have to do a trade union or is there a more elegant solution?

    My current sql result set looks like this:

    Activity codeActivity Code DescREGULAROTNONPRODDEPARTMENT
    00: status quo7409.25305.51603.25Information technology
    1010: special projects190.75170Information technology
    2020: Strategic initiatives1067520Information technology
    300: status quo57.500Information technology

    and I want my new results to look like this:

    Activity codeActivity Code DescREGULAROTNONPRODDEPARTMENT
    00: status quo7466.75305.51603.25Information technology
    1010: special projects190.75170Information technology
    2020: Strategic initiatives1067520Information technology

    Thank you

    John

    Select decode (activity_code, 30, 0, activity_code) activity_code, sum (regular), sum (ot)..,.

    t

    Group to decode (activity_code, 30, 0, activity_code)

  • Query result set...

    I can't determine a good word in my question. So, I think that my pseudocode below will be sufficient for this purpose.

    Oracle version: 11.2 g

    Data set
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT *
      FROM temp
    The result of the above query:
    COL1     DAY
    1     1
    2     1
    3     1
    4     1
    5     1
    6     1
    7     2
    8     2
    9     2
    10     2
    You the WISH result set:
    DAY COL_TOTAL
    1   21  
    2   55   -- 21 + 33 (the sum of day 1 + the sum of day 2)
    I realize that I can get the desired result, set above the code below. However, for my I have several other data points and 100 separate days I need to do for their actual issue. In doing so, a statement of the UNION 100 isn't exactly going to work.
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 1
    UNION ALL
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 2
    Published by: user652714 on August 13, 2012 21:55

    Hello

    I now see what you want. You can use this:

    select *
    from tt
    order by col_1;
    
         COL_1        DAY
    ---------- ----------
             1          1
             2          1
             3          1
             4          1
             5          1
             6          1
             7          2
             8          2
             9          2
            10          2
    
    10 rows selected.
    
    select day, sum(total) over  (order by  day) COL_TOTAL
    from
    (select day, sum(col_1) TOTAL
    from tt
    group by day
    );
    
        DAY  COL_TOTAL
    ---------- ----------
             1         21
             2         55
    
    2 rows selected.
    
  • get the result set in CSV

    How can I get a result set of a table as a comma-separated value? I saw there are dbms_utility.table_to_comma but don't know how to use it.

    For example,
    Select column_name from user_tab_columns where table_name = "TAB1".

    I want to get the result as col1, col2, col3

    I'm using Oracle 11 g.

    Your help is very appreciated. :)

    Hello

    in oracle 11, you can use:

    select
      LISTAGG(column_name,',') WITHIN GROUP (ORDER BY COLUMN_ID) CSV
    
    from
      user_tab_columns
    
    where
      table_name = 'PBCATCOL'
    
    ;
    
    CSV
    ---------------------------------------------------------------------------------------------------------------------------------------------
    PBC_TNAM,PBC_TID,PBC_OWNR,PBC_CNAM,PBC_CID,PBC_LABL,PBC_LPOS,PBC_HDR,PBC_HPOS,PBC_JTFY,PBC_MASK,PBC_CASE,PBC_HGHT,PBC_WDTH,PBC_PTRN,PBC_BMAP,PBC_INIT,PBC_CMNT,PBC_EDIT,PBC_TAG             
    
                                                                                                                                           
    

    Kind regards

    Peter

  • Combine queries to get the result set with max Y

    Hello
    I use forms 6i and db 10.2.0.1.0

    With the query below
    Select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete from usr_file_access_master
    Where ufam_ecode = '0004108';
    the result set is
    UFAM_USRGRP     UFAM_FILEGRP    UFA UFA UFA UFA
    --------------- --------------- --- --- --- ---
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   N   N   N
    EMPLOYEE        PERSONAL        Y   N   N   N
    Another query
    Select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
    Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
    and usr_usrgrp_lnk.uul_ecode = '0004108'
    gives the result
    UUL_USRGRP      UFL_FILE_GRP    UFL UFL UFL UFL
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   N   N   N
    I need to combine these two queries to get a separate result set with maximum Y

    Like here "MGMNT CV" is repeated in both the result set, but the first has more, then it should come from the combined result set. reverse-case also the same (such as "EMPLOYEE GENERAL")

    So I want to combine the queries so that I get the result as set below
    UserGroup       FileGroup       Rd Wrt Owrt Del
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        PERSONAL        Y   N   N   N
    Please help me to combine these queries

    Published by: Divya on August 14, 2011 21:24
    Changed the result set and the last exit

    NOT TESTED!

    select y.uul_usrgrp,
           y.ufl_file_grp,
           greatest(ufl_read,nvl(ufam_read,' ')) ufl_read,
           greatest(ufl_write,nvl(ufam_write,' ')) ufl_write,
           greatest(ufl_overwrite,nvl(ufam_overwrite,' ')) ufl_overwrite,
           greatest(ufl_delete,nvl(ufam_delete,' ')) ufl_delete
      from (select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete
              from usr_file_access_master
             Where ufam_ecode = '0004108'
           ) x,
           (select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete
              from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
             Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
               and usr_usrgrp_lnk.uul_ecode = '0004108'
           ) y
     where y.uul_usrgrp = x.ufam_usrgrp(+)
       and y.ufl_file_grp = x.ufam_filegrp(+)
    

    Concerning

    Etbin

    Edited by: Etbin on 14.8.2011 13:08
    deleted by group

  • Problem with the query result set * STILL a QUESTION *.

    Summary

    What I am tring to do is to return output to the data points that currently have no values.

    * Here it is sample data for reasons explaining my question (my data set is MUCH bigger)

    xTable
    YEAR    PEOPLE    ITEMS    TYPE_NUMBER TYPE_DESC    CLASS
    2010       1                 1              REG              1 
    2010        2        3         2             MISC             1
    2010        5        4         3             WEEK           1
    2010                             1             REG              2
    2010                             2             MISC             2
    2010                             3             WEEK           2
    2009       1                 1              REG              1 
    2009        2        3         2             MISC             1
    2009        5        4         3             WEEK           1
    2009                             1             REG              2
    2009                             2             MISC             2
    2009                             3             WEEK           2
    
    ... (there's over 100 other unique CLASS values)
    Desired output
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010         -            -            -                        -                         --  (Class 2 result set)
    
    /* FYI, If i wanted the class 1 result set it would look like this:
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010        8       7             16                    14                       -- (Class 1 result set)*/
    Oracle: 10.2 G
            select 2010 as yr,
                         nvl(f.people,'-') as people
                         nvl(f.items,'-') as items  
                         nvl(to_char(sum(f.people)),'-') as total_people,
                         nvl(to_char(sum(f.items)),'-') as total_items,
                         from Xtable,
                              (2010 as yr,
                              sum(items)as items
                              sum(people) as people
                              from xTable
                              where person_id = 99999
                              and   type_number in (1,2,3)
                              and year = 2010
                              and class = 2 
                              or class = 1
                              ) f
                         where person_id = 99999
                         and type_number in (1,2,3)
                         and yr = f.yr
                         and (year <= 2010 or year = 2010)
                         and (class = 2 or class = 1)
                         group by 
                         f.people,
                         f.items
    Currently, the query above will return no rows.

    Published by: user652714 on February 2, 2010 13:04

    How about this?

    SQL> WITH    xTable AS
      2  (
      3          SELECT 2010 AS YEAR, 1 AS PEOPLE, 0 AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      4          SELECT 2010 AS YEAR, 2 AS PEOPLE, 3 AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      5          SELECT 2010 AS YEAR, 5 AS PEOPLE, 4 AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      6          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      7          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      8          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 2 AS CLASS FROM DUAL
      9  )
     10  -- END SAMPLE DATA
     11  SELECT  YEAR
     12  ,       NVL(TO_CHAR(SUM(PEOPLE)),'-')    AS PEOPLE
     13  ,       NVL(TO_CHAR(SUM(ITEMS)),'-')     AS ITEMS
     14  ,       CLASS
     15  FROM    xTable
     16  WHERE   CLASS IN (1,2)
     17  AND     YEAR = 2010
     18  GROUP BY YEAR
     19  ,       CLASS
     20  ORDER BY CLASS DESC;
    
                    YEAR PEOPLE ITEMS CLASS
    -------------------- ------ ----- -----
                    2010 -      -         2
                    2010 8      7         1
    
  • Returns more than one result set. How?

    I have a stored Proc that returns 4 results for games, what to call them a page of cfm for each result set?
    Here's my proc. The Proc is a CFC

    umuayo wrote:
    > Hi,.
    >
    > The Proc is a CFC. I need to invoke the cfc from the cfm page to return the results of query cfstoredproc.

    Then, just do it.

    Of course you can only return a value from a function so you'll need
    to put these four results in a table or structure or something to
    group them.

    Then use the complex variable of your choice in the cfm page.

  • How to check if group policy is set on "don't sign is not on the users with temporary profiles?

    I work through the problem addressed in https://support.microsoft.com/en-us/kb/947215 (click here), namely: after creating a new user account, attempts to to the fail with the error "user profile service logon. User profile cannot loaded ".

    KB recommend checking to see if group policy is set on "don't sign do not on users with temporary profiles»

    How do I do that?

    General information...

    I inherited this computer.  Previously, he served as both a team of personal and school computer.  In my view, it is configured to be part of a homegroup, which I cannot access.  I intend to disable homegroup connections.  But I take my time to make sure I'm not breaking the functionality I need.

    Group Policy above have anything to do with homegroups?

    Despite this, the residential group, Control Panel does not appear should be the group policies.

    I find Microsoft Web pages that refer to a Group Policy Editor (gpedit.msc).  I only found on this computer (yet).

    Happy to the point of resources to the thread if you give us a link

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • How to dynamically access the SQLite result set?

    I want to dynamically access the SQLite result set. Since webworks does not support the "PRAGMA table_info (table_name); I save all newly created information tables in a single two-column table called schema. schema has two columns, table_name, and column_name.

    So I created a function to dynamically access the data in the table. I use the item = results.rows.item (i) and that the data access with item.column line.

    column is a variable that will receive the value of a schema representative of column_name. When I alert (column) I get the column_name is correct, but when I used item.column my results are "not defined".

    any advice on how to solve this issue.

    I managed to solve this issue. The solution is the following: the normal way to access the data of the variable item = results.rows.item (i) is item.column (where the column is the name of the column in the database table. To access the data dynamically, I Specifies a var col1 to assign different values in col1. I then access the data in the database using point [col1] hope that makes sense. If you need a further explanation contact me at [email protected]

  • JSON to the sql result set

    Hi all

    I have this requirement to convert the JSON format in the result set (with the lines and columns).

    is their in any case I can achieve this?

    I was able to successfully convert the sql result set in JSON format but difficult time to do the reverse.

    Flexibility:

    At some point, I expect the lines to return no more than 2 & about 50 columns maximum.

    Therefore, the JSON itself can be stored in varchar2 (4000) and not need to use CLOB. (If necessary to be passed as an argument to the function).

    Oracle version: 11.2.0.3

    Kind regards

    AAG

    There are at least the son on this site below:

    https://community.Oracle.com/thread/2505918

    https://community.Oracle.com/thread/3634280

    https://community.Oracle.com/thread/3557925

    https://community.Oracle.com/thread/2510292

  • How to create a new column of two different result sets

    How to create a new result column different two sets, both the result set uses the dimensions of different date.

    I got solutions for is to apply the filter in the formula in the column it itself, based on the requirement.

  • UNION and UNION ALL giving multiple result sets even if INTERSECT does not lines.

    Hello

    I have a set of two queries. I used the UNION to join the result set. When I used UNION ALL, I get a different result set.

    BT when I use INTERSECT, I m not getting all the lines.

    SO, which I guess is, as operation INTERSECT isn't Govind all the lines, then the UNION and UNION ALL of the result sets must be simliar.

    But I m getting different result sets.

    Please guide me.

    Thank you.

    Hello

    UNION returns separate lines; UNION ALL returns all rows that produce queries.

    INTERSECT has nothing to do with it.  You can have the lines in a single query.  For example

    Job SELECTION

    FROM scott.emp

    UNION - ALL THE

    SELECT 'FUBAR '.

    DOUBLE;

    In this example, there is no overlap between the 2 queries (INTERSECT would have 0 rows).

    UNION produces 6 lines, because the query at the top of the page produces 5 distinct lines (of 14 total ranks) and the background query 1.

    UNION ALL product lines 15: 14 of the request from top and 1 of the request from the lower part.

    I hope that answers your question.

    If not, post a test script (if necessary) and complete, including some UNION, UNION ALL queries INTERSECT.  Post of the CREATE TABLE and INSERT statements for all tables using those queries (with the exception of the commonly available rtables, such as those of the scott schema) and a specific question, such as "the UNION query all product...» I expect the UNION query to produce... because... but instead, it produces... Why is this?  It seems contractict... manual which says that... ».

  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

    --      ---     --      ---     -------

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Hotkey of the worksheet area of writing in the result set

    Y at - it a keyboard shortcut to switch between writing in the SQL worksheet and navigate (or copy,...) in the result set of a query run?

    That would make my job easier everyday!

    @Chris

    ALT + PagegDown in version 4.0

    No no not a nav of Ko to this v3.2 and earlier versions, has been saved as a bug.

Maybe you are looking for