Depicting multiple rows' data in one row

Hi All,
Pls. check the below query:
select manager_id mg_id, employee_id emp_id, last_name name from employees
where manager_id = '100'
and DEPARTMENT_ID = '80'if i run the following query, then o/p comes row wise; like below:
       mg_id           emp_id            name
       100             145                     Russell
       100             146                     Partners
       100             147                     Errazuriz
       100             148                     Cambrault
       100             149                     Zlotkeybut if i want the o/p like below; i.e; under manager # 100, all employees' emp_id and name should come in only ONE row NOT in multiple rows:
mg_id                   emp_id     name          emp_id       name       emp_id     name         emp_id     name                emp_id         name
100                             145             Russell     146       Partners        147     Errazuriz       148              Cambrault        149        Zlotkeypls. help me to sort out the above sought o/p.
kindly tell me if there is any posting guidelines (except "Plain Text Help" on the right side) in this forum. i tried a lot to post above two o/p in easily readable format, but couldn't do that.
Edited by: Shariful on Sep 20, 2009 4:28 AM
Edited by: Shariful on Sep 20, 2009 4:29 AM

Hi,
Shariful wrote:
Hi All,
Pls. check the below query:
select manager_id mg_id, employee_id emp_id, last_name name from employees
where manager_id = '100'
and DEPARTMENT_ID = '80'
if i run the following query, then o/p comes row wise; like below:
mg_id           emp_id            name
100     145     Russell
100     146     Partners
100     147     Errazuriz
100     148     Cambrault
100     149     Zlotkey
but if i want the o/p like below; i.e; under manager # 100, all employees' emp_id and name should come in only ONE row NOT in multiple rows:
mg_id                   emp_id     name          emp_id       name       emp_id     name         emp_id     name                emp_id         name
100     145     Russell     146     Partners     147     Errazuriz     148     Cambrault     149     ZlotkeyIf you want all the emp_ids and names concatenated into one big VARCHAR2 column, that's called String Aggregation
[AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
You can format that one big column so that it looks like separate columns.
If you want each emp_id and name in its own column, that's called Pivoting .
Look up "pivot" for various techniques. If you do not know exactly how many rows were in the original query (and therefore how many columns you'll need in the output), then it will require Dynamic SQL , which can be complicated.
Unfortunately, when you do search for "pivot", mlost of the hits will be things like "Search for pivot and you'll get lots of examples".
Re: Help for a query to add columns is one that actually has some information. It was a question very much like yours.
kindly tell me if there is any posting guidelines (except "Plain Text Help" on the right side) in this forum. i tried a lot to post above two o/p and query in easily readable format, but couldn't do that.Type these 6 characters:
(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Collecting data from multiple rows into one column

    I'd like to run a query and put a collection of items into one output column instead of multiple rows. See the example below:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    "CORE     10.2.0.5.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
         CREATE TABLE "SKIP"."INGREDIENTS"
       (     "INGRED_ID" NUMBER,
         "INGRED_NAME" VARCHAR2(20 BYTE),
         "STORES" VARCHAR2(20 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGREDIENTS
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (1,'SEA SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (2,'TABLE SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (3,'FLOUR','Piggly Wiggly');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (4,'YEAST',null);
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (5,'BEER','ABC Store');
      CREATE TABLE "SKIP"."PRETZELS"
       (     "PRETZEL_ID" NUMBER,
         "PRETZEL_NAME" VARCHAR2(20 BYTE),
         "PRETZEL_DESC" VARCHAR2(100 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.PRETZELS
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (1,'CLASSIC','Classic knot pretzel');
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (2,'THICK STICK','Straight pretzel, abt 1/2" in dia');
      CREATE TABLE "SKIP"."INGRED_XREF"
       (     "PRETZEL_ID" NUMBER,
         "INGRED_ID" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGRED_XREF
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,1);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,4);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,3);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,5);
    --  Constraints for Table INGRED_XREF
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("PRETZEL_ID" NOT NULL ENABLE);
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("INGRED_ID" NOT NULL ENABLE);
    {code}
    Desired output (note how the ingredients are all listed in one column, separated by commas):
    {code}
    PRETZEL_ID PRETZEL_NAME     PRETZEL_DESC                        INGREDIENTS
    1          CLASSIC          Classic knot pretzel                SEA SALT, TABLE SALT, YEAST
    2          THICK STICK      Straight pretzel, abt 1/2" in dia   TABLE_SALT, FLOUR, BEER

    See the FAQ : {message:id=9360005}
    Especially links concerning string aggregation.

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • Import xml data in Access when multiple rows use the same fieldname

    HI.
    First of all sorry for my english :-) I have a LiveCycle Designer ES form with multiple rows that I send via e-mail as XML data.
    example:
    Row 1
    Firstname: John  Lastname: Dow
    Row 2
    Firstname: Steve  Lastname: Austin
    The exported XML is OK but when I want to import it into my Access database, only one row is imported. I pretty sure that the problem comes from the fact that may exported XML use the same fieldname (what is important if I want to import data in the correct Access field) but I don't know what to do to be able to import all the rows of the same Form.
    Any idea?
    Thanks a lot
    Frederic

    Hi Viktor,
    In case of order recognition rules you should increase the relevancy in the newer version of the cartridge so appropriate ORR will be triggered. In other xqueries, you can try using new namespace as a model variable for each and every version of the cartridge
    Regards,
    JP

  • How to update multiple rows in one query using php

    i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

    Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
    In such a situation, you need four database tables as follows:
    students (student_id, student_name, etc.)
    courses (course_id, course_name, etc.)
    students_courses (student_id, course_id)
    attendance (student_id, course_id, dater)
    A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
    The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
    So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

  • How to process multiple rows of data into a single string

    Hello,
    I am trying to process multiple rows of text from an Oracle database into one field to display on a report as continuous text. Below is sample data. The text field is 55 characters wide so anything longer is broken into multiple rows. I need to recombine it for display.
    line          text
    1             IN THE N.E. QUADRANT OF THE INTERSECTION OF THE FAIRFAX
    2              COUNTY PARKWAY AND THE DULLES AIRPORT ACCESS AND THE T
    3             OLL ROAD AND SOUTH OF SUNSET HILLS ROAD
    I tried creating a formula field but it did not work, below is the code in Visual Basic syntax. I also tried using the Maximum() and UBound() functions without luck. I don't quite understand how to make the UBound() work; it threw a lot of errors.
    Dim i As Number
    Dim strLocDesc As String
    For i = 1 To count({LDS_AR_RL_COMM.ART_LINE_NUM})
        strLocDesc = strLocDesc & {LDS_AR_RL_COMM.ART_COMM_RMK}(i)
    Next i
    formula = strLocDesc
    Any ideas on how to solve this?

    Hello Allison,
    You can try this:
    Create a formula called @StoreText, place it in the details and have the following code in it:
    WhilePrintingRecords;
    Global StringVar Text1;
    Global StringVar TextRest;
    if {field.line} = 1 then
    Text1:= {field.text} else
    if {field.line} >= 2 then
    TextRest := TextRest+" "+{field.text};
    In the Group Footer you can have a formula called @GetStoreText with the following code in it:
    WhilePrintingRecords;
    Global StringVar Text1;
    Global StringVar TextRest;
    Text1+varTextRest;
    See how that works out for you.
    Regards,
    Zack

  • Writing multiple rows in one line, mysql statement. No strings are saved

    Hi, I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           Date FillDate = wdContext.currentContextElement().getFillDate();
           String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
           stmt1.setDate(1, FillDate);
           stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    I would like to know how to fix it.
    Other issue is that code below:
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           String sql1 = "INSERT INTO table1 (BirthDate1) VALUES (?)"; //BirthDate1 row in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
              stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
            Statement  st2=con.createStatement();
         String signature = wdContext.currentContextElement().getsignature(); //signature - context
         String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
         PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, signature);
         stmt2.executeUpdate();
         stmt2.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    Regards, Blamer.

    Hi,
    Fix for your first issue
    I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           Date FillDate = wdContext.currentContextElement().getFillDate();
           String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
           stmt1.setDate(1, FillDate);
           stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    I would like to know how to fix it.
    Change the line  stmt1.setDate(1, FillDate); to stmt1.setDate(2, FillDate);
    As a workarond for your following issue
    works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
            Statement  st2=con.createStatement();
         String signature = wdContext.currentContextElement().getsignature(); //signature - context
         String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
         PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, signature);
         stmt2.executeUpdate();
         stmt2.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    Try as follows
    PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, (signature == null ? "Value missing" : signature));
         stmt2.executeUpdate();
         stmt2.close();
    If the context attribute is null it will enter the text "Value Missing",
    Regards
    Ayyapparaj

  • Generating multiple rows from one physical row

    I was wondering if anyone has done or knows how to generate multiple rows for one physical row. In my query "SELECT Cust_No, Amount from Balances" if the amount is > 99,999.99 I want 2 rows returned, one with an amount of 90,000.00 and the other with an amount of 9,999.99. I'm thinking I need to use a view or function to return a result set but I'm not sure how.
    Thanks in advance,
    Allen Davis
    [email protected]

    James,
    Well your right in that you need a function, but also 3 views to accomplish that. I just wrote up the sql below and tested it. Basically you want the first view to return all records less than your cap of 99,999, thoes that exceed that will always return as 90,000 (see example on record PK 774177177). The second view returns money that remains AFTER the cap (in your case 9,999). The second view though also has to excude the ones less than the CAP.
    DATA and TABLE layout
    1) Table is called T1, columns are PK : primary key value, and N2 : some number column holding the MONEY amount
    2) data is below fromtable called t1 (10 records) ...
    select pk,n2 from t1 order by pk
    PK     N2
    117165529     100
    274000876     200000
    350682010     9999
    737652242     90000
    774177177     99999
    1369893126     1000
    1663704428     100000
    1720465556     8888
    1793125955     0
    1972069382     1000000
    Now see the records with money at 99,999 (just like in your example). You want 2 records, so the VIEWS now come into play. The view itself CALLS the function, this occurs when you select from the view. The function will either return 90,000 (your defined cap) or the remained after subtracting the money from 90,000. The 3 views are defined below (the FUNCTION which is shown after will have to be compiled first) ...
    --[VIEWS START]
    CREATE OR REPLACE VIEW VIEW1
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,1) FROM T1;
    CREATE OR REPLACE VIEW VIEW2
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,2) FROM T1 WHERE N2 >= 99999;
    CREATE OR REPLACE VIEW VIEW_ALL
    (PK,SHOW_MONEY)
    AS
    SELECT * FROM VIEW1
    UNION ALL
    SELECT * FROM VIEW2;
    --[VIEWS END]
    OK now for the actual function ...
    --[FUNCTION START]
    CREATE OR REPLACE FUNCTION
    FN_TRIM_MONEY
    PI_MONEY NUMBER,
    PI_VIEW_ID NUMBER
    RETURN NUMBER AS
    LS_TEMP VARCHAR2(2000);
    LI_TEMP NUMBER;
    LD_TEMP DATE;
    LI_CON_MONEY_MAX CONSTANT NUMBER := 90000;
    LS_RETURN VARCHAR2(2000);
    BEGIN
    IF (PI_MONEY > LI_CON_MONEY_MAX) THEN
    IF PI_VIEW_ID = 1 THEN
    LI_TEMP := LI_CON_MONEY_MAX;
    ELSIF PI_VIEW_ID = 2 THEN
    LI_TEMP := (PI_MONEY - LI_CON_MONEY_MAX);
    END IF;
    ELSE
    LI_TEMP := PI_MONEY;
    END IF;
    IF LI_TEMP < 0 THEN
    LI_TEMP := 0;
    END IF;
    LS_RETURN := LI_TEMP;
    RETURN LS_RETURN;
    END;
    SHOW ERRORS;
    --[FUNCTION END]
    I compiled the function and views with no errors. This is what I get when I query the 3 views ...
    --[VIEW 1]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    350682010     9999
    737652242     90000
    774177177     90000
    1369893126     1000
    1663704428     90000
    1720465556     8888
    1793125955     0
    1972069382     90000
    --[VIEW 2]
    PK     SHOW_MONEY
    274000876     110000
    774177177     9999
    1663704428     10000
    1972069382     910000
    --[VIEW ALL]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    274000876     110000
    350682010     9999
    737652242     90000
    774177177     90000
    774177177     9999
    1369893126     1000
    1663704428     90000
    1663704428     10000
    1720465556     8888
    1793125955     0
    1972069382     90000
    1972069382     910000
    So notice the PK entry 774177177 listed twice, once with 90,000 and other with 9,999. Also notice we now have 14 records from the original 10, meaning 4 records qualified for the split (all data from VIEW 2).
    This is why Oracle kicks ass, views and functions are very powerful when used together and can return pretty much anything.
    Thanks,
    Tyler D.
    [email protected]

  • Reg : Passing multiple rows of table data to the RFC

    Hi,
    I am passing one row of data from webdynpro table to table of RFC.
    How to pass multiple rows of data.
    Please help me out.
    Thanks
    Risha

    hi
    Person--->node(cardinality 1..n)
    FirstName-->Attribute
    LastName-->Attribute.
    Person1-->RFC table node.(cardinality 1..n)
    FName-->Attribute
    LName-->Attribute
    for(int i=0;i<wdContext.nodePerson().size();i++)
    //Retrieving values from table
       IPrivate<View>.IPersonElement    element1=wdContext.nodePerson().createPersonElement();
       String fname=element1.getFirstName();
       String lname= element1.getLastName();
       wdContext.nodePerson().addElement(element1);
    //Inserting into table of RFC
       IPrivate<View>.IPerson1Element element2=wdContext.nodePerson1().createPerson1Element();
       element2.setFname(fname);
       element2.setLname(lname);
       wdContext.nodePerson1().addElement(element2);
    Regards
    sowmya.

  • Procedure to insert data in multiple rows

    Hi,
    I need a stored procedure which inserts data into multiple rows..
    Ex: I need to have 3 columns in Procedure, where col3 has limit in size let's say 500.
    If user insert about 1500 in col3, i has to insert first 500 in row1 and 501 - 1000 in row 2 and 1001 - 1500 in row 3.
    Can any one help in creating procedure for above scenario.
    Thanks in Advance...
    Sree

    create table #t (id int, id1 int)
    WITH [1-20]
    AS
    SELECT row_number() over (order by number) rn,number
            FROM master..spt_values
             WHERE type = 'P'
             AND number BETWEEN 1 AND 20
     [21-30]
    AS
    SELECT row_number() over (order by number) rn,number
            FROM master..spt_values
             WHERE type = 'P'
             AND number BETWEEN 21 AND 30
    ) INSERT INTO #t 
      SELECT A.number,B.number FROM
         [1-20] A JOIN [21-30] B ON A.rn=B.rn
    SELECT * FROM #t
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • Load multiple rows of data in table

    hi i want to load multiple rows of data into table from flat file.
    i have oracle 10g enterprise edition, and can not find and envok
    sqlldr. edit command only does one line at a time.
    help please.

    thank you i got sqlldr.
    new problem
    i have created a control file customers.ctl
    LOAD DATA
    INFILE 'C:\ADD_CUST.TXT'
    INTO TABLE CUSTOMERS
    (CUSTOMER_NUMBER,LAST,FIRST,STREET,CITY,STATE,ZIP_CODE,BALANCE,CREDIT_LIMIT,SLSREP_NUMBER)
    and i have data to be loaded into the table in ADD_CUST.txt file.
    this is one line of data there are 9 similer lines.
    '124','ADAMS','SALLY','481 OAK','LANSING','MI','49224',818.75,1000,'03'
    now when i run sqlldr from cmd line below is the message i get.
    SQL*Loader: Release 10.2.0.1.0 - Production on Wed Feb 13 21:04:08 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    C:\>SQLLDR hr/hr control=CUSTOMERS.CTL log=customers.log
    SQL*Loader: Release 10.2.0.1.0 - Production on Wed Feb 13 22:10:19 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Commit point reached - logical record count 9
    Commit point reached - logical record count 10
    C:\>
    please help

  • Abap logic not fetching multiple rows from master data table

    Hi
    I just noticed that my logic is fetching only 1 row from master data table.
    ProdHier table
    PRODHIERACHY            Level
    1000                                  1
    1000011000                      2
    10000110003333              3
    10000110004444              3
    '10000110005555              3*
    logic only fetches one row of level 3, I would like to fetch all level 3 rows.
    DATA: ITAB type table of /BI0/PPROD_HIER,
          wa like line of ITAB.
    Select * from /BI0/PPROD_HIER INTO wa where /BIC/ZPRODHTAS = 3.
    IF wa-PROD_HIER(10) = SOURCE_FIELDS-PRODH2.
         RESULT = wa-PROD_HIER.
         ELSEIF wa-PROD_HIER(5) = SOURCE_FIELDS-PRODH1.
         RESULT = wa-PROD_HIER.
    ENDIF.
    ENDSELECT.
    thanks

    Hi,,
    I have implemented the logic in end routine and it still reads only the first row.
    I am loading only PRODH1 and PROD2 but now I want to get all values of PRODH3 from the master data table.
    The first 5 values are PRODH1 and first 10 values belongs to PRODH2.
    Whenever PRODH2 = 1000011000 in source I should get the following values
    10000110001110
    10000110001120
    10000110001130
    I have multiple rows of 1000011000 so my result should be
      1000011000               10000110001110
      1000011000               10000110001120
      1000011000               10000110001130
    DATA: ITAB type table of /BI0/PPROD_HIER,
    wa like line of ITAB.
    data rp type _ty_s_TG_1.
    Select  * from /BI0/PPROD_HIER INTO table itab where /BIC/ZPRODHTAS = 3.
    LOOP AT RESULT_PACKAGE INTO rp.
    read table itab into wa with key PROD_HIER(5) = rp-PRODH1.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
         ELSE.
    read table itab into wa with key PROD_HIER(10) = rp-PRODH2.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    Edited by: Bhat Vaidya on Sep 10, 2010 11:27 AM
    Edited by: Bhat Vaidya on Sep 10, 2010 11:37 AM

  • Update multiple rows involving spatial data

    Hi,
    i have 2 table, that are
    temp
    store_id
    store_state
    geom mdsys.sdo_geometry
    us_states
    state
    geom mdsys.sdo_geometry
    i have indexed both table with spatial index.
    If i wanna find state that temp.geom is inside us_states.geom using
    SQL> select state from us_states, temp
    where sdo_inside(temp.geom, us_states.geom) = 'TRUE';
    it's work
    but if i wanna update temp.store_state using
    SQL> update temp set store_state = (select state from us_states
    where sdo_inside(temp.geom, us_states.geom) = 'TRUE');
    it gives this error
    update temp set store_state = (select state from us_states where sdo_inside(temp.geom, us_states.geom) = 'TRUE')
    ERROR at line 1:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 62
    ORA-06512: at "MDSYS.SDO_3GL", line 192
    any idea how can i update multiple rows that involving spatial data?
    Thanks
    Hadi

    Hadi,
    There are a number of things wrong with the second item. First up you most likely will return more than one row, which is not allowed as the = expects only one item.
    Here is what I would use, which will update everything that meets the requirements, and ignore the rest:
    UPDATE (
    SELECT /*+ bypass_ujvc */
    state, store_id, store_state
    FROM temp, us_states
    WHERE sdo_inside(temp.geom, us_states.geom) = 'TRUE')
    SET store_state = state;
    With the /*+ bypass_ujvc */ you're telling the db to not worry about requiring a "unique join view condition" -- which roughly mean "trust me, my rows are key preserved." This is important since there is really no "hard" key-based relationship to tie the two together.
    However, unless you really think there are stores that border on two states, this will run much quicker with an anyinteract comparison.
    Bryan

  • Splitting comma seperated column data into multiple rows

    Hi Gurus,
    Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
    Below is the example:
    Source Data:
    Product         Size                                 Stock
    ABC              X,XL,XXL,M,L,S                 1,2,3,4,5,6
    Target Data:
    Product         Size                                 Stock
    ABC              X                                     1
    ABC              XL                                   2
    ABC              XXL                                 3
    ABC              M                                    4
    ABC              L                                      5
    ABC             S                                        6
    Which transformation we need to use for getting this output?
    Thanks in advance !

    Hello,
    Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
    Thanks

Maybe you are looking for

  • How do I delete a column for just one table and not all the others?

    I have multiple tabels in a Pages document. I want to delete some columns on some of the tables but keep them on the other tables. When I delete the columns it deletes all of them on all of the tabels and I dont want that.

  • SWI2_DIAG Error

    Dear Gurus, I need your help to solve the following issue: When I execute a ZXXX workitem, in SWI2_DIAG appear the following error diganosis: -The method cannot be executed -Application method has processed message 'E'; see long text -Notification of

  • Ocijdbc8 and thin drive

    My questions are regarding to use weblogic thin driver. The first question is if we need dll=ocijdbc8 in properties in config.xml. It looks to me ocijdbc8 is for thick driver only? The second question is why the server automatically add the "dll=ocij

  • Download error with CC programs/apps updates. Solutions?

    I am getting a download error when I try to update my CC programs/apps. Solutions?

  • JavaHelp - problems installing

    Hi, Just a quick question. I've downloaded JavaHelp and extracted the zip file. I assume that to install I need to run the src.jar file but it says that it is invalid or corrupt. Is this a Sun issue as my friend has had the same problem. Regards, Chr