Insert single coloum into 3 different coloum using a simple query

Hello All.
My problem is that.i have a table in which 3 coloums (Empno,Amounts,Codes) and table is like that.
Empno Codes Amounts
1 100 100
1 101 200
1 102 100
2 100 250
now i want to insert this data in a table like that...
empno amount(code 100) amount(code 101) amount(code 102)
1 100 200 100
so Please tell how to write a query for this problem.
Thanks ..
Edited by: hims on Sep 6, 2008 2:03 PM

Something like that :
SQL> with tbl as
  2  (select 1 id, 100 c1, 100 c2 from dual union all
  3   select 1 id, 101 c1, 200 c2 from dual union all
  4   select 1 id, 102 c1, 100 c2 from dual union all
  5   select 2 id, 100 c1, 250 c2 from dual)
  6  select id, sum(decode(c1,100,c2,0)) c100, sum(decode(c1,101,c2,0)) c101, sum(decode(c1,102,c2,0)) c102
  7  from   tbl
  8  group by id;
        ID       C100       C101       C102
         1        100        200        100
         2        250          0          0
SQL>Nicolas.

Similar Messages

  • How I can delete a row using a simple query?

    SZSLIFE_SPRIDEN_PIDM     SZSLIFE_SGBSTDN_TERM_CODE_EFF     SZSLIFE_SLRRASG_BLDG_CODE     SZSLIFE_SLRRASG_ROOM_NUMBER     SZSLIFE_SLRRASG_BEGIN_DATE     SZSLIFE_SLRRASG_END_DATE
    48547     199890                    
    48547     199990                    
    48547     199990     BLU     205     09/03/1999     12/23/1999
    48547     200010                    
    48547     200010     BLU     205     01/25/2000     05/25/2000
    48547     200090                    
    48547     200090     MOR     406     09/03/2000     12/23/2000
    48547     200110                    
    48547     200110     MOR     406     01/25/2001     05/25/2001
    48547     200190                    
    48547     200210                    
    48547     200290                    
    48547     200310                    
    48547     200390                    
    48547     200410                    
    48547     200610                    
    Here is what a simple question is probably for some of you; I can not get this to work. I need to delete all the rows that are duplicate like row #2 with the same SZSLIFE_SGBSTDN_TERM_CODE_EFF but with not
    SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER     
    I need to write a code where it counts the SZSLIFE_SGBSTDN_TERM_CODE_EFF and if it have the same (2 times.
    I need to delete the row without SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER
    The SZSLIFE_SLRRASG_BLDG_CODE NEEDS to be not null, because I do an insert in this table I need to be able to insert null values.
    How I can use a simple query where I can delete all the duplicate records without bldg_code and room number…
    Here is the table description
    SZSLIFE_SPRIDEN_PIDM NUMBER(8)
    SZSLIFE_SPRIDEN_ID VARCHAR2(10)
    SZSLIFE_SPRIDEN_LAST_NAME VARCHAR2(60)
    SZSLIFE_SPRIDEN_FIRST_NAME VARCHAR2(60)
    SZSLIFE_SPRIDEN_MI VARCHAR2(15)
    SZSLIFE_SGBSTDN_TERM_CODE_EFF VARCHAR2(6)
    SZSLIFE_SGBSTDN_STST_CODE VARCHAR2(2)
    SZSLIFE_STVSTST_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_STYP_CODE VARCHAR2(2)
    SZSLIFE_STVSTYP_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_LEVL_CODE VARCHAR2(2)
    SZSLIFE_STVLEVL_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_RESD_CODE VARCHAR2(10)
    SZSLIFE_STVRESD_DESC VARCHAR2(40)
    SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
    SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
    SZSLIFE_SLRRASG_BEGIN_DATE VARCHAR2(12)
    SZSLIFE_SLRRASG_END_DATE VARCHAR2(12)
    SLRRASG_ASCD_CODE VARCHAR2(2)
    I will appreciate any help!
    SLRRASG_ROLL_IND VARCHAR2(2)

    Thank you very much Sandeep, this works!
    1 DELETE SZSLIFE_TEMP2
    2 WHERE
    3 SZSLIFE_SGBSTDN_TERM_CODE_EFF
    4 IN
    5 (SELECT SZSLIFE_SGBSTDN_TERM_CODE_EFF
    6 FROM SZSLIFE_TEMP2
    7 GROUP BY
    8 SZSLIFE_SGBSTDN_TERM_CODE_EFF
    9 HAVING COUNT(*) > 1)
    10 AND
    11* SZSLIFE_SLRRASG_BLDG_CODE = ' '
    12 /
    4 rows deleted.
    The only thing here is that the SZSLIFE_SLRRASG_BLDG_CODE can not be defined as a a NULL, so I can not use
    where SZSLIFE_SLRRASG_BLDG_CODE is null
    Here is how those two columns are define:
    SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
    SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
    So,
    my question is it will be safe to do SZSLIFE_SLRRASG_BLDG_CODE = ' ' ?
    Again, it works, it deleted the rfows that I wanted...
    Thank you very much!!!
    Rogelio

  • How do you insert an image into a google map using a macbook?

    I am trying to put images into a Google map using my MacBook, but cannot seem to find any help. How do I insert an image into my Google map using my MacBook?

    Nothing complicated with your menu - very clear "ADD Image" but my menus are not as simple. Everytime I need to add an image I spend 5-10 minutes searching again. Wonder why so hard. I generally find Acrobat menus cryptic and unclear and I am big Adobe fan - use Illustrator, Photoshop, Dreamweaver, Premier, Fireworks etc - but Acrobat menus are like calculus in the dark.

  • Inserting Livecycle page into a different Livecycle form

    I've been searching around for an answer for a while, but I haven't seen a similar question.
    I currently have a Livecycle form made up of several pages, and I am trying to insert a page from a different form. For example, I have 8 pages in form A, and I am trying to insert form B into the 9th page of A, but I cannot find anything in the menus about inserting a page from another form. Can this be done? They have both been created in Livecycle Designer ES v 8.2.1, and they are both editable forms (which they need to be kept as such.)

    Hi,
    you can use fragments to reuse portions of a form in other form.
    Here's a small tutorial about fragments.
    http://forms.stefcameron.com/category/form-fragments/

  • Inserting song breaks into a cdr/vinyl using GarageBand?

    I'm using a stand-alone cd recorder to record my vinyl records onto cdr's. I would then like to use a built-in application (I have iLife on a new mac mini) to break up the songs and then load into iTunes as an album.
    It's a lot easier on the cd recorder to just drop the needle and record sides 1 and 2 as songs without hitting the song breaks on the fly. It would also be good to be able to remove the needle drop and lift off as well to clean things up.
    Is this possible on GarageBand or maybe iDVD?
    Thanks in advance,
    RickMac

    If you record into GB you can use the Cycle Region to export a portion of your recording (e.g. one of the songs). The move it to export another section. That way iTunes will have the songs separated. However, you will need to rename the songs in iTunes.

  • Premiere Pro CC inserting single frame into exported files

    I have never had this issue before today.
    A project I have been compiling off and on for several months was exported using AME via PPCC.
    In previous exports this issue did not come up at all.
    Here is the problem:
    The rendered videos (using Apple ProRes 422 HQ, QT H.264, and MPEG2 DVD) have a single frame insert between two stills in a montage.
    The previous render it appeared on a different photo a few seconds later in the program, like this:
    Again, these are single frame artifacts not found in the timeline in PPCC. They only appear as "flash frames" in the exported video.
    Anybody else seeing this? Is there a solution?
    Thanks
    Jeremy Praegitzer
    Adobe Premiere Pro CS5/CS6 Certified Associate
    TV Department Manager - Love A Child, Inc.

    Hi Jeremy,
    Thanks for posting on Adobe forums,
    Please provide us details of your systems:
    What is the OS and version ?
    What is the Graphics Card installed on the system ?
    How much Ram do you have ?
    Do you use any external Hard Drive ?
    and if you are using GPU Acceleration on Open CL, You can these issue on Export.
    Please switch GPU acceleration on Software only mode, (if using cuda enabled card then Cuda )
    Regards,
    Sandeep

  • Insert single column into oracle table

    i have a table t1 in whcih only one column is there
    Create table t1
    a number);now i need to load this column from a excel sheet.
    it have many rows and many column but need only corresponding column.
    please suggeest any way apart from external table and sql laoder.
    thanks

    No problem if you have thousands of rows.
    Say the value you want to insert is in column A of your excel file.
    In column B use the following formula:
    =CONCATENATE("insert into t1 values (";A1;");")And copy this formula to all other rows.
    Then select all the B column, copy it and paste it in a notepad file.
    Call the file as you want, for example c:\ins.sql
    open sqlplus and run
    SQL> @c:\ins.sqlAt the end don't forget to commit...
    Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

  • Insert single quote into the table

    Hi
    I have to insert values into a column that are retrieved by a select query on another table.
    The values inserted have single quotes (').
    Does anybody know how to do it?
    Thanks in advance

    If you get from one table and then insert in the other there shouldn't be any problem at all.
    SQL> create table blah_one as
      2  select 'Radha''s Sarma' col from dual
      3  /
    Table created.
    SQL> select * from blah_one
      2  /
    COL
    Radha's Sarma
    SQL> create table blah_two as
      2* select col from blah_one
    SQL> /
    Table created.
    SQL> select * from blah_two
      2  /
    COL
    Radha's Sarma
    SQL>Cheers
    Sarma.

  • How to insert a parameter into MySql from JSP using bean

    Hai.........
    The files i hav used are: DbConnection.java, LogBean.java, login.jsp, checkUser.jsp, existingUser.jsp, newUser.jsp...................
    I hav problem in newUser.jsp................................................
    ie: plz giv an appropriate code for this code:.........................................
    resultSet = connectionBean.execUpdate("insert into userLogin values('"+uName+"','"+pWord+"') ");
    Message was edited by:
    jaseemkhan

    Here is the code fragment.
    File file = new File ("c:\\t.gif");
    FileInputStream in = new FileInputStream (file);
    int len = (int)file.length();
    PreparedStatement pst = null;
    pst = conn.prepareStatement ("insert into blob_table values (1, ?)");
    pst.setBinaryStream (1, in, len);
    pst.executeUpdate();
    pst.close();
    conn.commit();

  • How to insert blank page into pages document when using word processing mode?

    I've recently created a 50+ page document using Pages '09. I started the document using word processing mode. Now, when I view in thumbnail mode and try to insert a blank page somehwere in the middle of the document, it won't allow me to select where I want. It just selects all the pages, as thought they are one section. I believe this is because I am in word processing mode. My question is, can I convert the document to layout mode so that each page represents it's own section, without losing what work I've already done? And if so, how?
    The document is entirely text boxes and images, so I don't have any need for word processing space. I just need new pages to act as blank templates for the text boxes and images I create.
    Is it possible to keep all my work as is, and convert the document to layout mode vs. word processing mode?
    Thanks!

    It just selects all the pages, as thought they are one section.
    That's because they are one section. You must insert section breaks to separate them. There is no need to use page layout which does make each page a separate section. You have to manually add each page & use text boxes or other containers for the text & link the text boxes.

  • Data to be exported from single ODS into 3 different files

    Hello All,
    There is an ODS having data for the last 3 quarters. I have to export this data as 3 files (one for each quarter) to the appln server. Any idea on how to achieve this using the infospoke & a single ODS?
    Regards,
    R.Ravi

    Hi Ravi,
    To carry out this in a process cahin you can use an event to trigger the extract structure.
    Once you have created an extract structure for a query, in the start condition selection option specify an event to trigger the extract structure. Call this event(you can use a Z-program) in the process chain which in turn will trigger the extract strucure to down load the file onto the application server.
    In our case we have deviced a Z-progarm to call the event which triggers the extract structure and track the completion of the download job. once the file is available in the appl srvr the process(ABAP program) gets completed and the subsequent process gets triggered.
    Regards

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • How to insert an in-line image into a table cell using Pages on OS X?

    How can I insert an image into a table cell using Pages (OS X) without it becoming the cell background? I want it to be a regular in-line image, but can't figure out how to do this for the life of me. Thanks!

    Welcome to Discussions.
    To insert an image into a cell, select the cell, then go to the Graphics Inspector and from the Fill drop down choose Image Fill and then select then image you want. You can now select from a new drop down how you want the image to fit.
    Walt

  • How to insert a UUID into multiple tables in the same form

    I am trying to insert a UUID into 2 different tables at the
    same time ie to let this be created in the form and then insert
    this ID into 2 linked tables in a database using Access.
    Does anybody have any suggestions on how to accomplish this?
    Thanks very much

    So you have one form that processes information for two
    tables, or do you
    have two forms (one for each table - except the UUID)?
    If it is one form just run two SQL insert statements. One for
    the primary
    table, then one for the related table.
    If it is two forms run the above two SQL statements then an
    update statement
    to finish filling the second table.
    Or am I completely misunderstanding the issue?
    Bryan Ashcraft (remove brain to reply)
    Web Application Developer
    Wright Medical Technology, Inc.
    Macromedia Certified Dreamweaver Developer
    Adobe Community Expert (DW) ::
    http://www.adobe.com/communities/experts/
    "weelco" <[email protected]> wrote in
    message
    news:esjtjj$qtc$[email protected]..
    > Thanks for your quick reply, and yes I do know how to do
    that however I
    > would
    > like to do this all in one form field so I would like to
    create the UUID
    > whith
    > the same form that also submits it to another table, is
    this possible or
    > do I
    > have to do that using multiple 'pages'?
    >

  • Insert same record on two different tables (no master detail)

    Hi all,
    I'd like to know how to insert 1 record into two different
    tables.
    the first table is corni_dati the second is cornidati_prev
    anytime someone inserts a new record both tables should be
    filled.
    if ((isset($HTTP_POST_VARS["MM_insert"])) &&
    ($HTTP_POST_VARS["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO corni_dati (corni_id,
    disciplina,
    codice_modulo, insegnanti, classi, obiettivi, prerequisiti,
    ud1, ud2,
    ud3, ud4, ud5, ud6, metodologia, collegamenti, verifiche,
    verifiche_note, durata, periodo_inizio, periodo_fine, note,
    indirizzo,
    modnum, modulo_titolo, `data`, compilato, descrizione) VALUES
    (%s, %s,
    %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
    %s, %s, %s,
    %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($HTTP_POST_VARS['corni_id'],
    "int"),
    GetSQLValueString($HTTP_POST_VARS['disciplina'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['codice_modulo'], "text"),
    GetSQLValueString($HTTP_POST_VARS['insegnanti'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['classi'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['obiettivi'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['prerequisiti'], "text"),
    GetSQLValueString($HTTP_POST_VARS['ud1'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud2'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud3'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud4'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud5'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['ud6'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['metodologia'], "text"),
    GetSQLValueString($HTTP_POST_VARS['collegamenti'], "text"),
    GetSQLValueString($HTTP_POST_VARS['verifiche'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['verifiche_note'], "text"),
    GetSQLValueString($HTTP_POST_VARS['durata'],
    "int"),
    GetSQLValueString($HTTP_POST_VARS['periodo_inizio'], "text"),
    GetSQLValueString($HTTP_POST_VARS['periodo_fine'], "text"),
    GetSQLValueString($HTTP_POST_VARS['note'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['indirizzo'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['modnum'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['modulo_titolo'], "text"),
    GetSQLValueString($HTTP_POST_VARS['data'],
    "date"),
    GetSQLValueString($HTTP_POST_VARS['compilato'],
    "text"),
    GetSQLValueString($HTTP_POST_VARS['descrizione'], "text"));
    mysql_select_db($database_itiscorni, $itiscorni);
    $Result1 = mysql_query($insertSQL, $itiscorni) or
    die(mysql_error());
    $insertGoTo = "creacodice_doc.php";
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
    header(sprintf("Location: %s", $insertGoTo));

    If you are doing this then you really should have a look at
    your database
    design. Read up on the first 3 normal forms.
    Pat.
    "darrel" <[email protected]> wrote in message
    news:ee77jg$302$[email protected]..
    >
    >
    > --
    >> Hi all,
    >> I'd like to know how to insert 1 record into two
    different tables.
    >
    > In your SQL query, just use two inserts:
    >
    > INSERT into TABLE1...; INSERT into TABLE2...
    >
    > Darrel
    >

Maybe you are looking for