How to remove certain common values of the columns in the result of a query?

Hello
I have a simple table with the structure:
CREATE TABLE EMP
(
ID VARCHAR2 (10 BYTE),
NAME VARCHAR2 (20 BYTE),
DESC1 VARCHAR2 (30 BYTE),
COUNTRY_ID VARCHAR2 (10 BYTE)
)

with values like this:
ID NAME DESC1 COUNTRY_ID

001 abc1 description 1 CON0000006
001 abc2 descr2 CON0000004
001 abc3 dsc3 CON0000003
CON0000005 descr4 abc4 002
CON0000001 descr5 abc5 002
003 abc6 dfrer CON0000001
ABC7 003 ioioi CON0000001
Lilli abc8 004 CON0000001
Can you please what will be the query that gives me output like this:

001 abc1 description 1
---     abc2     ---
---     abc3     ---
abc4 002 descr4
---     abc5     ---
003 abc6 dfrer
---     abc7     ---
004 abc8 lilli
edited by: bootstrap on August 11, 2011 21:46

Published by: bootstrap on August 11, 2011 21:48
with t as (
           select '001' id,'abc1' name,'description1' desc1,'CON0000006' country_id from dual union all
           select '001','abc2','descr2','CON0000004' from dual union all
           select '001','abc3','dsc3','CON0000003' from dual union all
           select '002','abc4','descr4','CON0000005' from dual union all
           select '002','abc5','descr5','CON0000001' from dual union all
           select '003','abc6','dfrer','CON0000001' from dual union all
           select '003','abc7','ioioi','CON0000001' from dual union all
           select '004','abc8','lilli','CON0000001' from dual
          )
-- end of on-the-fly data sample
select  case rn when 1 then id end id,
        name,
        case rn when 1 then desc1 end desc1,
        case rn when 1 then country_id end country_id
  from  (
         select  id,
                 name,
                 desc1,
                 country_id,
                 row_number() over(partition by id order by name) rn
           from  t
        )
order by name,
         rn
/

ID  NAME DESC1        COUNTRY_ID
--- ---- ------------ ----------
001 abc1 description1 CON0000006
    abc2
    abc3
002 abc4 descr4       CON0000005
    abc5
003 abc6 dfrer        CON0000001
    abc7
004 abc8 lilli        CON0000001

8 rows selected.

SQL> 

SY.

Tags: Database

Similar Questions

  • my phone asking me always Apple ID password of the account that I did not create. I have this account in my settings, but I don't know how to remove it. Thanks for the reply.

    my phone asking me always Apple ID password of the account that I did not create. I have this account in my settings, but I don't know how to remove it. Thanks for the reply.

    There are several places an identifier Apple is used on an iPhone.

    • If it's the Apple of a former owner of the phone ID, and it is in settings/iCloud grace to find my iPhone activated, ONLY the person who set up the Apple ID can remove (see: find my iPhone Activation Lock: a mechanism of extraction of the previous owner)
    • If it's the Apple ID in Settings/iTunes & App Store just log out, then log back with the correct ID of Apple.
    • Do the same for iMessage and Facetime, if that is where the Apple ID is used.
    • If he is asked during the updating of the apps means that applications have been purchased or downloaded using this code from Apple. To resolve this issue, you must remove the application, and then buy with your Apple ID.
  • How to remove a "people tag" in the Windows Live Photo Gallery?

    How to remove a "people tag" in the Windows Live Photo Gallery?  The
    has been named wrongly face and I don't understand how to remove.

    Hi pinecamp1972,

    We recommend that you ask your question in the forums photo gallery for better assistance.
    See Windows Live Photo Gallery Help Center

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to remove a user account on the HP 2000. I created two by mistake

    How to remove a user account on the laptop HP 2000.  I created two by mistake

    Sure...

    http://www.technoon.com/how-to-delete-user-account-in-Windows-8.html

  • How to use setViewportBounds (Bounds value) to the ScrollPane?

    How to use setViewportBounds (Bounds value) to the ScrollPane? This method is, visually, what for? I tried to put a specific Bounds.minY to have a precise scrolling in the axis Y in vain. I use the setVvalue() method to scroll, but it is not convenient to exactly locate a position in the coordinates of the node content listed in the scroll pane.

    The viewportBounds are the limits of the viewport (i.e., the visible part of the content) in the scrolling pane itself, if I understand correctly. The way to access programmatically is by setting the vValue property.

    I have not tried, but if you do something like

    scrollPane.setVmin(0);
    DoubleBinding vmax = new DoubleBinding() {
         { super.bind(scrollPane.viewportBounds(), content.heightProperty()); }
         @Override
         public double computeValue() {
            return content.getHeight() - scrollPane.getViewportBounds().getHeight() ;
         }
    };
    scrollPane.vmaxProperty().bind(vmax);
    

    to configure your component to scroll, then you can call setVvalue (...) and just pass a location of coordinates for your content node. This assumes that your content node is a region or a control; you will have to perhaps a little logic in the method computeValue() to deal with the cases where the display window is greater than the additional content.

  • How to remove an individual label in the navigation menu

    How to remove a single label in the navigation menu - for example I don't want a 'HOUSE' label visible when im on the home page.

    In order to be able to define your own label for a menu item, you would use a manual type menu. Other types of menus inherit page name as a Label for the menu items that you set in Page Properties or Plan mode.

    Or you could exclude the "HOME page" of the Menu options via the context menu in Plan/Design mode.

    Thank you

    Vinayak

  • How to remove headers and footers of the PDF by developing the plug-in by ourselves?

    How to remove headers and footers of the PDF by developing the plug-in by ourselves?

    The Adobe Acrobat version is 7.0 or higher.

    The version of the SDK is compatible with Adobe Acrobat.

    Currently, I'm looking on how to distinguish the 'headers or footers' with the other normal PDEElements, but so far I can't find any api on this subject.

    AH - Adobe 'headers' and 'feet '.

    Those are implemented by using optional content and content groups marked.  You can use the same API to locate them in a PDF file, if removal will require more work including some API at the level of the Cos.

  • How Oracle to store geometry values in the columns of the table?

    How Oracle to store geometry values in the columns of the table?

    Check this box:
    [Oracle Spatial User guide | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14255/toc.htm]

    Check other documents space here.
    [http://www.oracle.com/pls/db102/portal.portal_db?selected=7]

    Published by: Anantha R on August 20, 2009 13:43

  • How show only last row value in a column of OBIEE

    Hi Experts

    How show only last row value in a column of OBIEE


    Thank you
    V

    Hello
    Pull column criteria, which you want to display only last row. Filter Advanced sql apply now to this column as a.
    RCOMPTE ("customer D1". "C1 Cust Name") = MAX (RCOMPTE ("customer D1". " Cust C1 Cust Name name')) here is the column where I applied the filter.
    So, it gives only last row in the name column of the Cust.

    Awarded points if the answer
    Reference: http://forums.oracle.com/forums/ann.jspa?annID=939

    Kind regards
    Srikanth
    http://bintelligencegroup.WordPress.com/

  • Need to print the results of a query in a CASE statement

    I want to print the results of a query in a CASE statement:

    SELECT RUN_STATUS

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0 THEN 'NO JOBS RAN AFTER' |) (select sysdate - XXAFL_MINUTES MINUTE)

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where START_TS >

    (sélectionnez sysdate-MINUTES de XXAFL_MINUTES)) where RUN_STATUS is not null; e

    The query above subtracted 5 minutes from SYSDATE and he shoots XXAFL_MINUTES. I am doing this because we could change the number of minutes in the future. I want to print the number of minutes in the case statement.

    If I execute this statement, it throws an error stating:

    ORA-00937: not a single group group function

    00937 00000 - 'not a single-group function.

    * Cause:

    * Action:

    Error on line: 1 column: 96

    How can I include "select sysdate - MINUTES of XXAFL_MINUTES" in the CASE that it calculates the number of minutes and it prints with the results.

    Thanks in advance!

    Hey guys,.

    I found the solution:

    SELECT

    RUN_STATUS | TO_CHAR ((sélectionnez sysdate-MINUTES de XXAFL_MINUTES), 'HH24:MI:SS')

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0

    THEN "NO JOB RAN.

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where

    START_TS > (select sysdate - XXAFL_MINUTES MINUTE))

    where

    RUN_STATUS is not null;

    The output:

    NO JOBS RAN AFTER 09:07:54

    Thanks to you all!

  • Insert the result of a query select in another table

    Hello

    I have a strange problem when I try to insert all the results of a query select in another table, using the declaration of the order.

    With the declaration of COMMAND it works fine
    Work:
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". ' ' 'ACTIONS');
    ------------------------------

    But if I try to sort the result using the declaration of the ORDER, I have the following error:
    Error: ORA-00907 missing right parenthesis
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". "" "ACTIONS"
    ORDER BY
    "STOCK". ("' CODART_STO ASC ');
    ------------------------------

    Any idea?

    Thank you for your help,
    Angel.

    delete "()" to select

    create table test1 (a number, b varchar2(100));
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101;
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101 order by to_char(sysdate - level, 'D');
    
    select * from test1;
    
    drop table test1;
    
  • defining the results of a query to a variable

    Hi all

    I'm having a problem affecting the results of a query to a variable. What I'm trying to do, is to do an AJAX call to a .cfc file and pass back the results of the function. The main problem is, I'm again moving a block of HTML (resulting from a cfquery in a cfoutput) stored in a variable. My code is something like...

    < name cffunction = "getText" access = "remote" returntype = 'Cancel' >

    < datasource = "" #request.dsn # cfquery "name ="queryTable">"
    SELECT kort, infoB

    Of infoTable

    < / cfquery >


    < cfset result = ' <!-this is the part I'm stuck, I want the table go here. -> ">"

    < table >
    < cfoutput query = "tablequery" >
    < b >
    < td > #infoA # < table > < td > #infoB # < table >
    < /tr >
    < / cfoutput >
    < /table >


    < cfwddx action = "cfml2js" input = "" # result # ' toplevelvariable 'o' = > "

    < / cffunction >

    It is a simplified version of what I want to do, but you get the idea...

    Is it still the right way to go about this?  Thank you

    That's what I get for trying the E-mail response feature!  Are you not happy, that I double checked my post.

    You could do a lot of string concatenation here to do stuff like"& Kort &""& infoB &""> time and time again."  But in reality the tags is so much easier to use.



      

        
      

    #infoA #.#infoB #.

  • I need to return the result of a query on a stored procedure

    I need to return the result of a query to a stored procedure, I mean when I run a stored procedure it returns a result set in a select statement.
    Best regards...

    Hello.

    Do you really want a stored procedure for this?
    Why not just a script that contains the query?

    Assuming that you don't really want a stored procedure, you'll have to decide what to do with the results.
    An option is a slider.

    For example, you can write a procedure of this type to hold the query:

    CREATE OR REPLACE PROCEDURE USP_TEST
    (     out_cursor     OUT     SYS_REFCURSOR
    )
    IS
    BEGIN
         OPEN  out_cursor
         FOR     SELECT     *
              FROM     scott.emp;
    END  USP_TEST;
    /
    SHOW ERRORS
    

    You can move the cursor to another procedure for handling.

    You could test this in SQL * more by creating a variable blond:

    VARIABLE     usp_test_cursor     REFCURSOR;
    
    EXEC  usp_test (:usp_test_cursor);
    
    PRINT     :usp_test_cursor
    
  • Export the results of a query to a CSV file

    Hello

    My requirement is that I need to export the results of a query to a CSV file. Can someone please suggest a way to also include the names of columns in the CSV file?

    Thanks in advance.

    Annie

    Following code comes from asktom. I changed to include the column header. This will get your CSV file desired for a given query.

    create or replace function  dump_csv( p_query     in varchar2,
                                          p_separator in varchar2
                                                        default ',',
                                          p_dir       in varchar2 ,
                                          p_filename  in varchar2 )
    return number
    AUTHID CURRENT_USER
    is
        l_output        utl_file.file_type;
        l_theCursor     integer default dbms_sql.open_cursor;
        l_columnValue   varchar2(2000);
        l_status        integer;
        l_colCnt        number default 0;
        l_separator     varchar2(10) default '';
        l_cnt           number default 0;
    
         l_colDesc          dbms_sql.DESC_TAB;
    begin
        l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    
        dbms_sql.parse(  l_theCursor,  p_query, dbms_sql.native );
    
        for i in 1 .. 255 loop
            begin
                dbms_sql.define_column( l_theCursor, i,
                                        l_columnValue, 2000 );
                l_colCnt := i;
            exception
                when others then
                    if ( sqlcode = -1007 ) then exit;
                    else
                        raise;
                    end if;
            end;
        end loop;
    
        dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 );
    
        l_status := dbms_sql.execute(l_theCursor);
    
         dbms_sql.describe_columns(l_theCursor,l_colCnt, l_colDesc);
    
         l_separator := '';
    
         for lColCnt in 1..l_colCnt
         loop
                utl_file.put( l_output, l_separator ||  '"' || Upper(l_colDesc(lColCnt).col_name) || '"');
                   l_separator := p_separator;
         end loop;
    
         utl_file.new_line( l_output );
    
        loop
            exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
            l_separator := '';
            for i in 1 .. l_colCnt loop
                dbms_sql.column_value( l_theCursor, i,
                                       l_columnValue );
                utl_file.put( l_output, l_separator ||  '"' ||
                                        l_columnValue || '"');
                l_separator := p_separator;
            end loop;
            utl_file.new_line( l_output );
            l_cnt := l_cnt+1;
        end loop;
        dbms_sql.close_cursor(l_theCursor);
    
        utl_file.fclose( l_output );
        return l_cnt;
    end dump_csv;
    

    The original link is below.

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:95212348059

    Thank you
    Knani.

  • How to remove fonts and re - add the cc of InDesign

    Im trying to grope although some questions my indesign trial, I just loaded keep saying "indesign is not working, windows is looking for a solution" then the only option is to close.

    I tried uninstalling, reinstalling same update to windows 8.1 (on my sony 21-press). It didn't fix it.

    I found some instructions here but I do not understand how to actually find and delete fonts... I found some somewhere in a folder called PFM, (cut and copied to my desktop) and now I forgot where to put them back! I think I was tired all day trying to solve this. And no technical support available on weekends...

    Hope that someone would have a suggestion... (in laymen with certain capabilities to resolve the conditions)

    I'm trying to follow these instructions that indesign CC hangs after startup - Windows 8

    and these https://forums.adobe.com/message/5431757#5431757#5431757

    But I don't know if this means Windows fonts, or fonts adobe where to find or... (and if that's the real problem?)

    -do my best!

    1. exit InDesign

    2 remove all the fonts in the fonts folder and add a small batch of fonts in

    3. launch InDesign

    4. If it does not crash, quit InDesign and add some more fonts.

    If it hangs, you know one of this batch is the problem, close down more far.

    e.g. divide policies into halves, add half of the fonts in > if crashes > add half of the batch that causes the crash > half of that to reduce the list

    Look out for fonts with special characters in the name. Some examples of fonts problem reported by the community are:

    • Ithornet
    • TYPO3 - Medium.ttf
    • Typo3Normal.ttf
    • Batang.ttf
    • LET Savoye
    • IndyPimp
    • ImpactLabel

    The problem with fonts has been fixed, as far as I know, so this isn't the problem, if you are patched to version 9.2 of ID CC. You should be able to reinstall those that you deleted by a right click on it and choose Install.

    As to which is the cause of the crash, I really have no idea, but it wouldn't surprise me if it is a driver problem. There is a forum dedicated, monitored by staff from adobe at https://forums.adobe.com/community/download_install_setup/creative_cloud_faq which may be able to offer more help. I'm going to suggest you re-post there rather than have me move this thread to the off-chance someone here might have some thoughts as well.

Maybe you are looking for

  • Could not load 'live' Xfinity TV Go in 40 Firefox (Windows 7)

    When you run Xfinity TV Go, after selecting "Live TV" and a program option, I get empty a screen with a message "Load video" and a bar of progression with 3 points. However, no content loads. I have let it run up to 30 minutes - same result. TV Go wo

  • Skype crashes when opening of cat

    Okay, so. I updated my computer, and when I turned on Skype; I continued to get crash reports on it for example "Skype has stopped working, click here to close. Skype crashes when I opened discussions to send/reply to all the messages that I did. So

  • Problems to install apps on my watch with the help of iPhone 5 s

    Try to install apps on my watch, but he just said "install...". » Nothing happens? watchOS2.1 and iOS 9.2.1

  • Synchronized not regenerated multifunction AO AI

    I am trying to build a VI that reads and writes a signal simultaneosly to use as a test of the device. I want the signal to be non regenerative and I want to read 80kS/s with at least 4096 samples. I built my VI begin with the standard model of produ

  • boolien use of case selection switches

    Hi all I want to use the switches of boolien for the selection of cases in triggered mode. I mean I have a 4 switches (like lock mode when you press the trigger) when I pressed and released the button a case corresponding to the switch to be executed