How to display row to columns without using pivot keyword

hi,
could someone help me how to dispaly rows into columns without using pivot keyword and actuall my scenario is,iam having two tables with names and sample data is shown below
ID PROJECT MID MINAME TASKID TASKNAME
1     PROJ1     1     AA     100     PR1_TASK1
1     PROJ1     3     CC     102     PR1_TASK3
1     PROJ1     4     DD     103     PR1_TASK4
1     PROJ1     5     EE     104     PR1_TASK5
1     PROJ1     6     FF     105     PR1_TASK6
2     PROJ2     5     EE     114     PR2_TASK1
2     PROJ2     6     FF     115     PR2_TASK2
2     PROJ2     7     GG     116     PR2_TASK3
2     PROJ2     8     HH     117     PR2_TASK4
2     PROJ2     9     JJ     118     PR2_TASK5
2     PROJ2     10     KK     119     PR2_TASK6
2     PROJ2     1     AA     120     PR2_TASK7
The output should display project and count of tasks in particular milestone as shown below
project AA BB CC DD EE FF GG HH JJ KK
1 2 0 1 5 3 2 0 2 1 0
2 1 2 0 2 1 0 2 4 3 1
Thanks in advance ,
vvr

WITH t1 AS
(SELECT 1 ID,
         'PROJ1' PROJECT,
         1 MID,
         'AA' MINAME,
         100 TASKID,
         'PR1_TASK1' TASKNAME
    FROM DUAL
  UNION
  SELECT 1, 'PROJ1', 3, 'CC', 102, 'PR1_TASK3'
    FROM DUAL
  UNION
  SELECT 1, 'PROJ1', 4, 'DD', 103, 'PR1_TASK4'
    FROM DUAL
  UNION
  SELECT 1, 'PROJ1', 5, 'EE', 104, 'PR1_TASK5'
    FROM DUAL
  UNION
  SELECT 1, 'PROJ1', 6, 'FF', 105, 'PR1_TASK6'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 5, 'EE', 114, 'PR2_TASK1'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 6, 'FF', 115, 'PR2_TASK2'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 7, 'GG', 116, 'PR2_TASK3'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 8, 'HH', 117, 'PR2_TASK4'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 9, 'JJ', 118, 'PR1_TASK5'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 10, 'KK', 119, 'PR1_TASK6'
    FROM DUAL
  UNION
  SELECT 2, 'PROJ2', 1, 'AA', 120, 'PR1_TASK7' FROM DUAL)
SELECT id project,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'AA'
              AND id = t_out.id),
           0) AA,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'BB'
              AND id = t_out.id),
           0) BB,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'CC'
              AND id = t_out.id),
           0) CC,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'DD'
              AND id = t_out.id),
           0) DD,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'EE'
              AND id = t_out.id),
           0) EE,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'FF'
              AND id = t_out.id),
           0) FF,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'GG'
              AND id = t_out.id),
           0) GG,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'HH'
              AND id = t_out.id),
           0) HH,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'JJ'
              AND id = t_out.id),
           0) JJ,
       NVL((SELECT mid
             FROM t1
            WHERE miname = 'KK'
              AND id = t_out.id),
           0) KK
  FROM (SELECT DISTINCT id FROM t1) t_out
PROJECT     AA     BB     CC     DD     EE     FF     GG     HH     JJ     KK
1     1     0     3     4     5     6     0     0     0     0
2     1     0     0     0     5     6     7     8     9     10As I understand, you want MID of MINAMEs displayed ? But output is not like yours.. What is exactly your requirements?

Similar Messages

  • How to display Rows as Columns in JSF?

    I am using dataTable component to get data for my Menu, i have one column in it which returns me the data, because its automatically adding <tr> and <td> tags to it, its showing data in tabular form.
    I want to show output Horizontally instead of Vertically the way its showing.
    Is their any way i can display Rows as Columns?
    Code:
    ==============================================
    <div class="bodyarea">
    <div id="location">
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
    <f:verbatim><ol></f:verbatim>
    <h:column>
    <f:verbatim><li></f:verbatim>
    <h:outputLink id="crumbID" value="#{bread.menuLink}">
    <h:outputText id="crumpName" value="#{bread.menuLabel}"/>
    </h:outputLink>
    <f:verbatim></li></f:verbatim>
    </h:column>
    <f:verbatim></ol></f:verbatim>
    </h:dataTable>
    </div>
    </div>
    Thank you

    Table is not the html element for you, in this situation.
    I would use a dataList component (distributed with myfaces implementation).
    dataList is able to return a list of item, and using css you will be able display in a horizontal grid. (otherwise you can use layout="grid" in dataList).
    Anyway...my impression is that who made JSF was not really understanding how a html programmer like to write his code.
    Why do JSF gives us only the possibility to write list of items throught tables?
    Why do JSF prints error messages throught tables?
    Why div is not a standard component?
    This is an incredible lack...
    I see also other incredible lasks...but they don't concern html ;) .

  • How to auto update date column without using trigger

    Hi,
    How to write below MYSQL query in Oracle 10g :
    CREATE TABLE example_timestamp (
    Id number(10) NOT NULL PRIMARY KEY,
    Data VARCHAR(100),
         Date_time TIMESTAMP DEFAULT current_timestamp on update current_timestamp
    I need to auto update the Date_Time column without using trigger when ever i update a record.
    Example shown below is from MYSQL. I want to perform the below steps in ORACLE to auto update Date_Time column.
    mysql> INSERT INTO example_timestamp (data)
    VALUES ('The time of creation is:');
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The time of creation is: | 2012-06-28 12:37:22 |
    mysql> UPDATE example_timestamp
    SET data='The current timestamp is: '
    WHERE id=1;
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The current timestamp is: | 2012-06-28 12:38:55 |
    Regards,
    Yogesh.

    Is there no functionality in oracle to auto update date column without using trigger??
    I dont want to update the date column in UPDATE statement.
    The date column should automatically get updated when ever i execute an Update statement.

  • How can i join additional column without using a query

    Hi,
    I created a report using a base query; Now i want to add an additional coloumn to it without using another table i.e. from no new query; That additional column is complex computed value from different tables created for each record; How can i attach it to each record;
    thanks in advance
    prasanth

    Add a formula column in your existing query.

  • How to convert row data into columns without using pivot table?

    Hello guys
    I have a report that has several columns about sales call type and call counts
    It looks like this:
    Calls Type Call Counts
    Missed 200
    Handled 3000000
    Rejected 40000
    Dropped 50000
    Now I wanna create a report that look like this:
    Missed call counts Handled Call counts Rejected Counts Drop counts Other Columns
    200 300000000 40000 50000 Data
    So that I can perform other calculations on the difference and comparison of handled calls counts vs other call counts..
    I know pivot table view can make the report look like in such way, but they cant do further calculations on that..
    So I need to create new solid columns that capture call counts based on call types..
    How would I be able to do that on Answers? I don't have access to the RPD, so is it possible to do it sololy on answers? Or should I just ask ETL support on this?
    Any pointers will be deeply appreciated!
    Thank you

    Thanks MMA
    I followed your guidance and I was able to create a few new columns of call missed count, call handled counts and call abandoned counts.. Then I create new columns of ave missed counts, ave handled counts and so forth..
    Then I went to the pivot view, I realized there is a small problem.. Basically the report still includes the column "call types" which has 3 different types of call "miss, abandon and handled". When I exclude this column in my report, the rest of the measures will return wrong values. When I include this column in the report, it shows duplicate values by 3 rows. It looks like this:
    Queue name Call types Call handled Call missed Call abondoned
    A Miss 8 10 15
    A Handled 8 10 15
    A Abandoned 8 10 15
    in pivot table view, if I move call type to column area, the resulted measures will become 8X3, 10X3 and 15X3
    So is there a way to eliminate duplicate rows or let the system know not to mulitply by 3?
    Or is this as far as presentation service can go in terms of this? Or should I advice to provide better data from the back end?
    Please let me know, thanks

  • How to display rows as columns?

    Hi,
    I am simulating my problem with the following example.
    I have two tables, book_info contains book_id(primary key), book_name and the other table is author_info contains id(primary key), book_id and author. One book may have maximum upto THREE authors.
    BOOK_INFO
    =========
    book_id category book_name
    1 a ABC
    2 a PQR
    3 b XYZ
    AUTHOR_INFO
    ===========
    id book_id author
    1 1 aaaaaa
    2 1 bbbbbb
    3 1 cccccc
    4 2 pppppp
    5 2 qqqqqq
    6 3 xxxxxx
    I need output like different columns using a sql query WHERE category = 'a'.
    book_id book_name author1 author2 author3
    1 ABC aaaaaa bbbbbb cccccc
    2 PQR pppppp pppppp
    We are using Oracle 9i/NT environment. Urgent please.
    Thank you.

    Vijaya,
    Looks like I just answered this question, though your table layout is pretty much the same. Here what I said ...
    There actually is a couple ways to do this, but the term is called FLATTENING. The method I like is with a function and a view (I'm a huuuuge fan of views). It has some draw backs performance wise if doing this on allot of data, but the results are well worth it. Anyway the code is below. The table is T1, the view it makes is V1. The function is called FN_REC_FLAT. Some sample output is also included.
    16:46:11 SQL> SELECT T1.N1,T1.N2,T1.C1 FROM TABLE_NAME_HERE T1 ORDER BY T1.N1,T1.N2;
    N1 N2 C1
    -1 1 TEST
    1 1 THIS
    1 2 IS RECORD
    1 3 NUMBER 1.
    2 1 THIS IS
    2 2 RECORD
    2 3 NUMBER 2.
    3 1 AND THIS
    3 2 IS RECORD
    3 3 NUMBER 3.
    10 rows selected.
    CREATE OR REPLACE FUNCTION
    FN_REC_FLAT(PI_FLAT_KEY IN NUMBER,PS_FLAT_DATA IN VARCHAR)
    RETURN VARCHAR AS
    CURSOR CUR_T1 IS SELECT * FROM TABLE_NAME_HERE T1 WHERE T1.N1 = PI_FLAT_KEY ORDER BY T
    REC_T1 TABLE_NAME_HERE%ROWTYPE;
    LS_FLAT_DATA VARCHAR2(2000);
    LS_RETURN VARCHAR2(2000);
    BEGIN
    LS_FLAT_DATA := NULL;
    OPEN CUR_T1;
    FETCH CUR_T1 INTO REC_T1;
    WHILE CUR_T1%FOUND LOOP
    LS_FLAT_DATA := (LS_FLAT_DATA || ' ' || REC_T1.C1);
    FETCH CUR_T1 INTO REC_T1;
    END LOOP;
    LS_RETURN := TRIM(LS_FLAT_DATA);
    RETURN LS_RETURN;
    END;
    Function created.
    CREATE OR REPLACE VIEW V1 (N1,C1) AS SELECT DISTINCT T1.N1,FN_REC_FLAT(T1.N1,T1.C1) FROM TABLE_NAME_HERE T1;
    View created.
    16:46:12 SQL>
    16:46:12 SQL> SELECT T1.N1,T1.C1 FROM V1 T1 ORDER BY T1.N1,T1.C1;
    N1 C1
    -1 TEST
    1 THIS IS RECORD NUMBER 1.
    2 THIS IS RECORD NUMBER 2.
    3 AND THIS IS RECORD NUMBER 3.
    16:46:12 SQL>
    Note that the function takes in N1 as the root level for the flatten key. N2 is the sort order. In you case this would be EMP_ID and EMP_INFO_SEQ_NUM. The C1 is EMP_INFO. T1 is the table alias and TABLE_NAME_HERE ... well I'll let you figure that part out ;).
    Hope this helps,
    Tyler D.

  • How to get a new column without using update(plz check with the requirment)

    write a query to display current sal and new sal for all employees
    condition
    if job='MANAGER' and deptno in (10,20) then make newsal increased by 15% to current salary.
    if job !='MANAGER' and deptno in (10,20) then make newsal increased by 25% to current salary.

    Hi,
    Here's one way to do it:
    SQL> select empno,ename,job,deptno,sal, case
      2              when job='MANAGER' and deptno in (10,20) then 1.15 * sal
      3              when job <>'MANAGER' and deptno in (10,20) then 1.25 * sal
      4              else
      5                  sal
      6              end as new_sal
      7  from emp            ;
         EMPNO ENAME      JOB           DEPTNO        SAL    NEW_SAL
          7369 SMITH      CLERK             20        800       1000
          7499 ALLEN      SALESMAN          30       1600       1600
          7521 WARD       SALESMAN          30       1250       1250
          7566 JONES      MANAGER           20       2975    3421,25
          7654 MARTIN     SALESMAN          30       1250       1250
          7698 BLAKE      MANAGER           30       2850       2850
          7782 CLARK      MANAGER           10       2450     2817,5
          7788 SCOTT      ANALYST           20       3000       3750
          7839 KING       PRESIDENT         10       5000       6250
          7844 TURNER     SALESMAN          30       1500       1500
          7876 ADAMS      CLERK             20       1100       1375
         EMPNO ENAME      JOB           DEPTNO        SAL    NEW_SAL
          7900 JAMES      CLERK             30        950        950
          7902 FORD       ANALYST           20       3000       3750
          7934 MILLER     CLERK             10       1300       1625
    14 rows selected.
    SQL>If your requirements aren't satisfied, let me know it.
    Edited by: Manguilibè KAO on 18 janv. 2012 03:16

  • How to transpose the data records (rows) to column(lists) using apd

    Hi,
      how to transpose the data records (rows) to column (lists) using apd  in sap bw.
    I do not want to use abap routine.only use the transpose rows to list  transformation .
    Pls provide the step by step procedure .
    thanks,
    Nimai

    Save youe file to transpose as a csv and in the header row of your file for the columns you want to transpose you need to put some soer of a tag before the column name (ie your colum header was for a period budget will be something lie 2011001:ZFIBDD)
    1. You will need to create a new apd process (rsanwb)
    2. Insert a "Read from Data File" data source object and map it file (,csv)
    3. insert a transpose object into your apd process (middle row 4th one over in the transformations section)
    4. under the definition tab in the transformation object select all the columns that are to be transposed into rows and move them to the transformed area, the grouping fields section should contain the rows that you want to now be columns
    5.under the transformation tab enter in the seperator you selected  under the Field Name/Infoobject area (ie. ZFIBDD)
    6. under the details tab  you need to enter in all the fields to be transformed and tner the transposition field (ie ZFIBDD)
    7. Then you can insert a set of transformations and a DSO and link the newly transposed fields into that.
    hope that helps

  • Display distinct rows from Oracle table without using "DISTINCT" keyword.

    How to retrieve distinct rows from oracle table without using 'DISTINCT' keyword in SQL?
    Thanks in advance.
    Mihir

    Welcome to the forum.
    Besides GROUP BY you can use UNIQUE instead of DISTINCT as well, but that's probably not wanted here ;) , and the ROW_NUMBER() analytic:
    SQL> create table t as
      2  select 1 col1 from dual union all
      3  select 1 from dual union all
      4  select 2 from dual union all
      5  select 3 from dual union all
      6  select 4 from dual union all
      7  select 4 from dual;
    Table created
    SQL> select col1 from t;
          COL1
             1
             1
             2
             3
             4
             4
    6 rows selected
    SQL> select distinct col1 from t;
          COL1
             1
             2
             3
             4
    SQL> select unique col1 from t;
          COL1
             1
             2
             3
             4
    SQL> select col1 from t group by col1;
          COL1
             1
             2
             3
             4
    SQL> select col1
      2  from ( select col1
      3         ,      row_number() over (partition by col1 order by col1) rn
      4         from   t
      5       )
      6  where rn=1;
          COL1
             1
             2
             3
             4

  • Need help in displaying Rows to Columns

    Hi,
    I am facing problem in displaying Rows to Columns
    I am using pivot function:
    select *
    from
    (select vendor_name
    from tablea)
    pivot
    (count(vendor_name)
    for vendor_name in ('a,b,'c'));
    its working fine showing vendor_name and count
    but when i want to display the output as:(How to include the Salalry column in the query?)
    Name:{a b c}
    Sal Total:(400,600,800}
    Any help will be needful for me

    Not sure what you mean:
    select  *
      from  (select deptno,sal from emp)
      pivot(sum(sal) for deptno in (10,20,30))
            10         20         30
          8750      10875       9400
    SQL> SY.

  • How can I change excel column header using Labile.

    Dear Experts,
                          How can i change excel column header using LabVIEW.
    Thanks for any and all help!
    M.S.Sivaraj.
    Sivaraj M.S
    CLD

    As I said in my previous post, column headers in Excel are merely row 1 cells. May be I missing something here, so please be more explicit with your question.
    I guess you are using the Excel Report tools, and you want to modify an existing sheet. From my limited experience with the Excel Report tools, it is not possible to open an existing woorkbook (except as template...), so the answer to your question should be "Forget it"...
    The work around is to use the example I pointed for you before, and either to write the whole new colum headers as a string array, starting in A1, or to write a single string to a given cell in row 1.
    Hope this helps 
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • How to create a viewobject dynamically without using wizard

    Hi,
    I am Using jDEV 11G, i need to create a viewobject dynamically without using wizard, without binding from any entity.
    Actually my intention is to make a grid like in .Net, when a user want to create a new row in RichTable without using DB.
    just like shopping cart.
    i have done thsi code:
    ViewObjectImpl view=new ViewObjectImpl();
    view.addDynamicAttributeWithType("Att1","String",null);
    view.addDynamicAttributeWithType("Att2","String",null);
    view.addDynamicAttributeWithType("Att2","String",null);
    Row rw=view.createRow();
    rw.setAttribute("Att1","First1");
    rw.setAttribute("Att2","First2");
    rw.setAttribute("Att2","First3");
    view.insertRow(rw);
    I have a RichTable , i need bind this viewobject into that.
    Edited by: vipin k raghav on Mar 10, 2009 11:39 PM

    Hi Vipin,
    You can create the view object with rows populated at run time.
    [http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcquerying.htm#CEGCGFCA]
    For reference of how to create an empty rwo at run time on button click
    [http://kohlivikram.blogspot.com/2008/10/add-new-row-in-adf-table-on-button.html]
    ~Vikram

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to Start process in ProcessChain Without using Repeat option?

    How to Start process in ProcessChain Without using Repeat option?

    Se16 -- table:RSPCPROCESSLOG - click on display entries.
    Entet the variant, instance start date (this info you can get from the "display message" of PC.
    Now execute to display the table entries of RSPCPROCESSLOG.
    Next goto SE37 transaction --enter RSPC_PROCESS_FINISH
    Take the entries from the above table to set the input parameters of the FM.
    I_logid = log_id(from above table)
    I_type = type(from above table)
    i_variant = varaint (from above table)
    i_instance = (from above table)
    Click on F8(EXECUTE)
    now the actual process is set to gree and the process chain will be triggered (rest of the PC with out repeating the step from where is was red).

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

Maybe you are looking for

  • Only year not full date in ABAP HR

    i need only year to be selected by the user on selection screen. do anyone know any function which only gives year .

  • My ipod serial no  only have 10 digits

    I don't understand, i try to enter my ipod serial no. and it only has 10 digits and it also has the HP symbol on the back. my friend got his about a month after me and he has 11 digits and doesn't have the HP symbol in the back... can somebody tell m

  • Streams on Standard Edition

    Hallo list, Iam trying to configure Oracle streams on SE 10g database ,this Master database will replicate data to many Personal or XE databases. My question is this configuration possible under SE 10g ? i have read that SE support message queining a

  • Importing wildcard identity SSL cert in ASA?

    Where would I find instrutions on how to import CA certified identity SSL wildcard certficate ( like *.company.net - ) in ASA? The CSR for the wildcard certificate was not generated out of the ASA unit.

  • XI Content Description

    Hi, In general i get into SAP Service Market , under download and i find XI Standard content for many SAP Applications. XI content is vast and it has given for many appl , how to find the dexcription and usuage of the content. Do we need to download