Rows to columns question

Hi all,
10.2.0.3 database.
I need to convert MONTH ROW into columns. I tried few things with SYS_CONNECT_BY_PATH without any luck.
Example:
HOST     DB     TS     MONTH     SIZE_MB
=========== === ====== ======= =======
cltcrmspdb01     NP5     AIMD01     2005-08     4198
cltcrmspdb01     NP5     AIMD01     2005-12     4627
cltcrmspdb01     NP5     AIMD01     2005-05     2414
cltcrmspdb01     NP5     AIMD01     2005-06     3966
cltcrmspdb01     NP5     AIMD01     2006-04     5215
cltcrmspdb01     NP5     AIMD01     2006-07     6288
cltcrmspdb01     NP5     AIMD01     2006-05     5903
cltcrmspdb01     NP5     AIMD01     2005-07     3977
cltcrmspdb01     NP5     AIMD01     2006-06     6004
cltcrmspdb01     NP5     AIMD01     2006-08     6312
cltcrmspdb01     NP5     AIMD01     2005-11     4298
cltcrmspdb01     NP5     AIMD01     2006-02     4591
cltcrmspdb01     NP5     AIMD01     2005-09     3956
cltcrmspdb01     NP5     AIMD01     2006-10     971
cltcrmspdb01     NP5     AIMD01     2005-10     3850
cltcrmspdb01     NP5     AIMD01     2006-01     4835
cltcrmspdb01     NP5     AIMD01     2006-03     5429
cltcrmspdb01     NP5     AIMD01     2006-09     6312
HOST DB TS 2005-08 2005-09 2005-10 ...... 2006-09
============ === ====== ======= ======= ======= =======
cltcrmspdb01 NP5 AIMD01 4198 4627 2414 6312
Can somebody help me here. thanks in advance

You need pivot query like this, (I didn't list all the months)
select HOST, DB, TS,
           max( decode( month, '2005-08', SIZE, null ) ) 2005_08,
           max( decode( month, '2005-09', SIZE, null ) ) 2005_09,
           max( decode( month, '2005-10', SIZE, null ) ) 2005_10,
           max( decode( month, '2005-11', SIZE, null ) ) 2005_11
      from ( select HOST, DB, TS, MONTH, sum(SIZE_MB) SIZE
               from yourtable
              group by  HOST, DB, TS, MONTH)
     group by HOST, DB, TS

Similar Messages

  • Freezing Rows and Columns Question

    In a spreadsheet I have Row 1 Frozen as a Header row for descriptions and headings of different columns of expenses
    Is it possible to Freeze the very bottom row of all the totals? I am imagine that you could scroll up and down all the rows in between, but always see the decriptions at the Top Header Row and the Totals at the Bottom Row
    Is this possible?
    thanks
    MS

    Trackpad vs Mouse is just a matter of getting used to using the one you will use.
    Your profile indicates OS X v10.8 (Mountain Lion), so this answer applies to Numbers '09.
    With a trackpad, start by selecting the columns or rows you want to move. Click any cell to activate the table, then position the pointer over the tab of the first column to be selected. If the pointer changes to a vertical line crossed by a double headed arrow, shift it slightly until it changes bck to the selection pointer (black arrow pointing up and left). Then click and drag across the column Header tabs to select the columns.
    When the columns are selected, move the mouse pointer to a position just to the left of the letter labeling the first selected column. With the pointer positioned there, use your thumb to press and hold the mouse button/trackpad down, then use a finger to drag the columns down until they 'detach' from the table. Change the direction of drag to move the detached columns to the location where you want them. When the boundary showing where you want to places the columns changes to a thick blue line, release the mouse button/track pad (lift your thumb, but not your finger) to drop the columns into position.
    Rows:
    Change:
    "vertical line crossed by a double headed arrow" to "horizontal line..."
    "Drag across the column tabs..." to "Drag down the row tabs..."
    "Drag the columns down until..." to "Drag the rows right until..."
    Otherwise the same instructions.
    Regards,
    Barry

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • Row to Column in 10g

    Hello All,
    I have a requirement where I have to convert rows to columns and vice versa in 10g.
    Pivot isn't supported in 10g.
    Actual query looks like this
    change_name    primary_key_id
    ASSET              1501 
    COLLATERAL         1501
    ASSET              1502
    COLLATERAL         1510
    ASSET              1503
    COLLATERAL         1515
    Required Output:
    change_table_name  Asset      Collateral
    Primary_key_id         1501       1501
    Primary_key_id2        1502     
    Primary_key_id3                     1510
    Primary_key_id4        1503     
    Primary_key_id5                     1515Thx
    Shank.
    Edited by: SamFisher on May 16, 2012 7:48 PM

    Hi,
    SamFisher wrote:
    Hello All,
    I have a requirement where I have to convert rows to columns and vice versa in 10g.
    Pivot isn't supported in 10g.Pivot can be done in any version of Oracle.
    The PIVOT keyword of the SELECT command isn't supported in Oracle 10. That's only one way of pivoting.
    Actual query looks like this
    change_name    primary_key_id
    ASSET              1501 
    COLLATERAL         1501
    ASSET              1502
    COLLATERAL         1510
    ASSET              1503
    COLLATERAL         1515
    Required Output:
    change_table_name  Asset      Collateral
    Primary_key_id         1501       1501
    Primary_key_id2        1502     
    Primary_key_id3                     1510
    Primary_key_id4        1503     
    Primary_key_id5                     1515
    I think you want something like this:
    SELECT     'Primary_key_id
         || TO_CHAR ( NULLIF  ( ROW_NUMBER () OVER (ORDER BY  NVL ( a.primary_key_id
                                             , c.primary_key_id
                      , 1
               )          AS change_table_name
    ,     a.primary_key_id     AS asset
    ,     c.primary_key_id     AS collateral
    FROM          table_x      a
    FULL OUTER JOIN     table_x  c  ON  a.primary_key_id  = c.primary_key_id
    -- Next 4 lines added after Ankit, below
                       AND     a.change_name     = 'ASSET'
                       AND     c.change_name     = 'COLLATERAL'
    WHERE     a.change_name     = 'ASSET'
    OR     c.change_name     = 'COLLATERAL'
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    This generates a unique change_table_name for each row. I don't see how you get the values you said you wanted associated with the other columns. That is, I have the same question as Justin:
    Justin Cave wrote:
    ... How do you know that 1502 goes with primary_key_id2 and not primary_key_id3 or 4 or 1?Perhaps you don't really care which change_table_name is given to each row, just so long as they are unique, and numbered with consecutive integers (except for 1). If you really do need exactly what you posted, explain how you get it. You probably just need to change the analytic ORDER BY clause.
    Edited by: Frank Kulash on May 17, 2012 6:56 AM
    Corrected query

  • Table name input. and output i need  all rows and columns  using procedures

    hi,
    question: table name input. and output i need all rows and columns by using procedures.
    thanks,
    To All

    An example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Report with multiple dimensions in Row and Column with EvEXP

    Hi
    We are currently running BPC 7.0 SP3 and try to create the report(or schedule) with more 2 x 2 dimensions in the row and column.
    e.g.
    row dimension : Outer row is Entity, Inner row is Account
    column dimension : Outer column is Time, Inner row is Category
    We created the report with  2 x 2 dimensions like above e.g. with EvEXP and EvNXP, NOT EvDRE
    based on default dynamic template:Template13.xlt(Nested Row, 2 x 1 dimensions defined by EvEXP and EvNXP formula).
    However, when expanding the dimension with double click these dimensions or change CV of the report with  2 x 2 dimensions defined by EvEXP and EvNXP formula,
    error occurs on EvEXP and EvNXP formula and can't retrieve the result correctly.
    [Question]
    Can't we create the report with more 2 x 2 dimensions in the row and column using EvEXP and EvNXP function ?
    We understand that we can make the report with more 2 x 2 dimensions in the row and column if using EvDRE.
    Thank You in advance
    Kenya

    Thank you for your advice.
    I understand that we should use EvDRE when creating the report with multiple dimension in the row/column because EvEXP have some erros, poor performance, etc.
    Then, we have two questions.
    1)
    >plus they had some errors in the designs.
    what kind of errors they have as an example?
    2)
    >If you must build the EVEXP and EVNXP, I would suggest building the template from scratch
    We built the simple template with just 2 x 2 dimension from scratch.
    But this report doesn't work well when double-click the dimension or changing CV...
    Would you please check the following template?
    <https://sapmats-de.sap-ag.de/download/download.cgi?id=RCZE1ME4YSORY3DCDO4NNMANZLBL1L5ZBUOB2F71YVNVS8XDJW>
    It would be greatly appreciated if you could give me your advice for the template.
    Thank you again
    And my best regards,
    Kenya

  • How can I preserve row and column addresses on multiple cells at once in Numbers?

    How can I preserve row and column addresses on multiple cells at once in Numbers 3.2.2? I do a lot of rearranging and sorting and want to reference cells in other sheets. After entering the formulas (example: '=Sheet1::Table 1::H126') I will sort the table and the formulas will not move with the sort.  I think I can fix this by going cell by cell checking the 'preserve row' and 'preserve column' boxes when editing the formula.  I want to avoid having to go one by one.  I know that checking the boxes creates a formula like this: '=Sheet1::Table 1::$H$126'  I have also tried entering this manually and filling down but it doesn't include the preservations (the $$) in the autofill.  If there is another way to remedy my sorting problem that would also be welcomed!
    THANKS!!

    The title of the post is this
    How can I preserve row and column addresses on multiple cells at once in Numbers?
    I restated the Question as follows
    Can "Preserve Row" an / or "Preserve Column" be set on multiple cells at the same time.
    In both cases it is not asked if multiple cells can be set to....
    That is a given.
    Step back a second...  It is like selecting multiple cells and setting the text color of the currently selected cells to red. This can be done. More than one cell at a time modified because they are currently selected.
    Whats is being asked is:  if more than one cell is selected at the same time can the settings "Preserve Row" an / or "Preserve Column" be applied. No table I put up will help with that question.
    YES or NO
    If YES how?

  • Arrays[][] - row and column

    Evening All...
    Just a quick question regarding arrays. My program is working but I am trying to tidy it up.
    public class Arrays{
    static int firstArray[][]= new int [][] {{8,5},{9,3}};
    static int secondArray[][]= new int [][] {{1,7},{4,8}};
    static int thirdArray[][]= new int [][] {{0,2,4},{9,6,8}};
         static int fourthArray[][]= new int [][] {{2,1,0},{6,2,3}};
    public static void main(String[] args)
         multiply(secondArray,firstArray);
         multiply(firstArray,thirdArray);
         public static void multiply( int[][] x, int[][] z)
         int array2[][] = new int [3][3];
         int 1r = x.length;
         int 1c = x[0].length;
         int 2r = z.length;
         int 2c = z[0].length;
         //for(etc...)
    //      (Rest of program)
    I want to edit the array.--------int array2[] = new int[3][3]; (up 9 lines)
    Instead of specifying it as [3][3] for size.
    I would like to say new int - length of row and column - im pretty sure it is similar to
    the ints below - but cant seem to get the correct combination.
    Thanks in advance for any help folks.

    - you can use variables to specify array dimensions
    - you can get the (1D) dimension of an array by using the "attribute" theArray.length . Knowing that a 2D-array is indeed an array of arrays, you can indirectky get the size oif the second dimension too:
    public static void multiply( int[][] x, int[][] z) 
    int array2[][] = new int [x.length][x[0].length];                  
    }Of course this shoud be robustified to protect against x or x[0] being null (but in this case the multiplication is probably doomed anyway).
    Regards,
    J
    Edited by: jduprez on Mar 14, 2011 10:45 PM
    And please, in the future, use tags around code text, when posting code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Formulas results outside of row and column axis

    The report has an area of row axis and column axis. This area is where the results from BW are displayed.
    We have a requirement where we would have to create formulas using the BW Analyzer results of the row axis and column axis and display the results after the last row of this area.
    For example, after the BW Analyzer displays the result area to the Excel, we are required to take Excel Cell D10 * C7 and put the results to B33.
    <b>B33 = D10*C11</b>
    Excel row 30 is the last row from the row axis result area.
    I have searched through the forum for Cell Editor, but it seems that the requirement is to use 2 structures and use Cell Editor only when there is a formula collision. Our requirement has 1 structure, but I guess we can create the other structure for the column axis results. But still I think Cell Editor is a computation of formula collision within the row and column axis result area.
    My question is will Cell Editor meet our requirement if we want to get formula results from the row and column axis and then display the results outside of the row and column axis result area?
    Our approach was to use the Excel cell formulas in the workbook or possibly macros, but it seems that the Excel formulas will do.
    Would someone clarify about the Cell editor for this requirement and how would you approach this?
    Would this be effective to do the formulas from the query level? We are working on 3.5 SP11.

    Can Cell editor do the following:
    1. Create structures
    2. Run the query
    3. The results of the structures are displayed in the row and column axis of the BEx Analyzer
    4. Save as a workbook
    5. Use the Cell Editor to pick and choose the cells (Not the Excel cells) to create formulas
    6. The formula results are then displayed outside of the row and column axis.
    Would this be another approach?
    What scenario can Cell editor be used? What scenario can Cell editor not be used?
    Thanks

  • Select row and column from header in jtable

    hello i have a problem to select row and column from header in jtable..
    can somebody give me an idea on how to write the program on it.

    Hi Vicky Liu,
    Thank you for your reply. I'm sorry for not clear question.
    Answer for your question:
    1. First value of Open is item fiels in Dataset2 and this value only for first month (january). But for other month Open value get from Close in previous month.
    * I have 2 Dataset , Dataset1 is all data for show in my report. Dataset2 is only first Open for first month
    2. the picture for detail of my report
    Detail for Red number:
    1. tb_Open -> tb_Close in previous month but first month from item field in Dataset2
    espression =FormatNumber(Code.GetOpening(Fields!month.Value,First(Fields!open.Value, "Dataset2")))
    2. tb_TOTAL1 group on item_part = 1
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)))
    3. tb_TOTAL2 group on item_part = 3 or item_part = 4
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) + ReportItems!tb_TOTAL1.Value )
    4. tb_TOTAL3 group on item_part = 2
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) - ReportItems!tb_TOTAL2 .Value)
    5. tb_Close -> calculate from tb_TOTAL3 - tb_Open
    expression =FormatNumber(Code.GetClosing(ReportItems!tb_TOTAL3.Value,ReportItems!tb_Open.Value))
    I want to calculate the value of tb_Open and tb_Close. I try to use custom code for calculate them. tb_close is correct but tb_Open is not correct that show value = 0 .
    My custom code:
    Dim Shared prev_close As Double
    Dim Shared now_close As Double
    Dim Shared now_open As Double
    Public Function GetClosing(TOTAL3 as Double,NowOpening as Double)
        now_close = TOTAL3 + NowOpening
        prev_close = now_close
        Return now_close
    End Function
    Public Function GetOpening(Month as String,NowOpen as Double)
        If Month = "1" Then
            now_open = NowOpen
        Else    
            now_open = prev_close
        End If
        Return now_open
    End Function
    Thanks alot for your help!
    Regards
    Panda A

  • How to convert data from rows into columns

    Hi,
    I have a sql table and the data looks like this
    GLYEAR GLMN01 GLMN02 GLMN03 GLMN04
    2007 -109712.40 6909.15 4758.72 56.88
    2007 -13411.32 19132.9 -5585.07 4362.64
    Where GLyear reprsents Year and GLMN01 is February, GLMN02 is March and so on,
    Now i want my output to be something like this which i want to insert into another table
    GLYear GLMonth GLAmount
    2007 February -109712.40
    2007 March 6909.15
    2007 April 56.88
    My new table has 3 columns, GLYear,GLMonth,GLAmount.
    Can someone please help me with the select statement on how to do this, i can work with the inserts.
    Thanks.

    I want you to check these form tread they have the same discussion as you.  They will definitely solve your problem
    http://blog.jontav.com/post/8344518585/convert-rows-to-columns-columns-to-rows-in-sql-server
    http://dba.stackexchange.com/questions/19057/convert-rows-to-columns-using-pivot-in-sql-server-when-columns-are-string-data
    http://stackoverflow.com/questions/18612326/how-to-convert-multiple-row-data-into-column-data-in-sql-server
    I hope this helps you in solving your problem. 
    Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer

  • Table -- sum of rows and columns?

    I was wondering if anyone has a suggestion to how I can easily generate the sum of each row and column in a two dimensional table? This is what I've got so far:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int i = 0; i < table.length;
              i++) {
             for (int j = 0; j < table.length;
              j++)
              table[i][j] = Terminal.lesInt(); // Terminal is a class that can read the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values
         for (int i = 0; i < table.length;
         i++) {
         for (int j = 0; j < table[i].length;
              j++) {
              System.out.print("\t" + table[i][j]);
         System.out.println();
         // sum of first column
         int sumColumn = 0;
         for (int i = 0; i < table.length;
         i++) {
              sumColumn += table[i][0];
         System.out.print("\nSum:\t");
         System.out.println(sumColumn);
    Example of output:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3
            4       5       6
    Sum:    5This is the output I'd like:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3     6
            4       5       6     15
    Sum:    5     7     9One way of getting the sum for all the columns is to make a for-loop for each one of them, but there has to be a better way. I could apply the same hack to get the sum of the rows, but I still wouldn't know how to get the layout I want.

    After many hours of frustration I finally solved it (for-loops can be confusing, man) after I got a hint from a post in another forum: http://www.linuxquestions.org/questions/showthread.php?postid=624021#post624021
    A more logical name to the integers actually helped a lot too. And here's the final product:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++)
              table[row][col] = Terminal.lesInt(); // Terminal is a class that reads the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values and sum of each row
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++) {
              System.out.print("\t" + table[row][col]);
             int sum = 0;
             for (int col = 0; col < table[0].length;
               col++) {
              sum += table[row][col];
             System.out.println("\t" + sum);
         System.out.print("\nSum:");
         // sum of each column
         for (int col = 0; col < table[0].length; // table[0].length is the length of row 0 (the number of columns)
              col++) {
             int sum = 0;
             for (int row = 0; row < table.length; // table.length is the number of rows
               row++) {
              sum += table[row][col];
             System.out.print("\t" + sum);
         System.out.println();
    }

  • In Numbers, I want to make 3 rows 50 columns into 3 columns 50 rows.

    In just a simple Numbers 09 spreadsheet, no charts, I'm trying to convert the rows and columns to columns and rows to more easily work with the information without scrolling across the page.  I would be able to see the information on one page and more easily print a one page documents.  I can't seem to figure it out; and the Help option has not been helpful unless you are working with a chart.  I don't want a chart, I want to work with the spreadsheet and cells.
    Any ideas!  I'm sure it is operator error, but it's something I'm not familiar with.  I'm new to Apple and definitely new to numbers.
    Thanks,
    Sandra

    You may go to my iDisk (address below)
    download :
    For_iWork:iWork '09:for_Numbers09:Transpose.zip
    Expand the archive
    You will get two scripts.
    One which transpose the values
    One which transpose keeping formulas if the original table is a living one.
    Yvan KOENIG (VALLAURIS, France) samedi 8 octobre 2011 09:29:28
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • SAP HANA View Row to Column Transpose

    Hello Guys
    What is the best way to transpose rows to columns within a Hana Model. I can find many articles that talk about Column to Row transpose.
    Source:
    Customer
    Dim 1
    Dim 2
    1000
    A
    1100
    1000
    B
    1200
    1000
    C
    1300
    Target:
    Customer
    A
    B
    C
    1000
    1100
    1200
    1300
    Thanks

    Not as an answer, but as a question: Are there three rows *only* resp. could they be granted? Or you wanna have the amount dynamic, i.e. count the same customers and than created the amount of required columns?

  • Converting from rows to columns

    Converting Rows to Columns
    We have one business requirment where they want to convert rows to columns. The data we are talking about is 2-3 TB of data. Data looks something in this format.
    Table Structure
    Date_1 Unit_Number Data_ID Data_Value
    2013-01-02 00:00:00 100013 123 671
    2013-01-02 00:00:00 100014 131 771
    2013-01-02 00:00:00 100015 281 812
    2013-01-02 00:00:00 100016 712 979
    2013-01-02 00:00:00 100017 715 719
    Pivoted table
    Date_1 RY XY HJ KD IK GH HH KK TK RT ...
    2013-01-02 00:00:00 671 771 812 979 719 979 719 980 799 79
    2013-01-02 00:10:00 671 771 812 979 719 979 719 980 799 79
    and so on
    We are pivoting this data using query and creating view using query something like below
    select a.date_1 date_1 a.unit_number system_number,
    max(CASE WHEN a.data_id= 123 then a.DATA_Value END) RY,
    max(CASE WHEN a.data_id= 281 then a.DATA_Value END) XY,
    max(CASE WHEN a.data_id=712 then a.DATA_Value END) HJ,
    max(CASE WHEN a.data_id=715 then a.DATA_Value END) KD,
    max(CASE WHEN a.data_id=666 then a.DATA_Value END) IK,
    max(CASE WHEN a.data_id=231 then a.DATA_Value END) GH,
    max(CASE WHEN a.data_id=881 then a.DATA_Value END) HH,
    max(CASE WHEN a.data_id=734 then a.DATA_Value END) KK,
    max(CASE WHEN a.data_id=734 then a.DATA_Value END) TK,
    max(CASE WHEN a.data_id=724 then a.DATA_Value END) TK,
    from FROM table_name group by 1,2
    We also tried pivot clause but still no major improvement in performance.
    There are about 40 such rows that we are trying to convert into columns. We created indexes, Primary, Secondary and referencial ones to tune this overall query. Also added paritions, We find this conversion works fine for smaller query, however for larger set of data we get high CPU and IO and also often runs into spool error. The data set we are runing on this query are about 3-4 TB. There is another table where we have about 100 rows which we need to convert into one row and again size goes to 4-5 TB
    Questions I have
    1) Is there better way to convert columns to Rows?
    2) What options can be use to reduce CPU, IO and Spool error?
    3) Does Orage 11g datawarehouse any feature which will hellp us here
    4) Any other appproach or design suggested here that will help us?
    This design is pushed by our business due to flexibility this design offers and we are runing into performance and we are trying to make this work without impacting CPU, Spool and IO
    Any suggestions would help us here, thanks for reading this

    Hi,
    Here's one way to do that:
    WITH     got_times     AS
         SELECT     MAX ( CASE
                   WHEN  msg_line = 'LONGITUDINAL REFRESH HAS BEGUN'
                   THEN  msg_datetime
                  )          AS start_time
         ,     MAX ( CASE
                   WHEN  msg_line = 'LONGITUDINAL REFRESH HAS COMPLETED'
                   THEN  msg_datetime
                  )          AS end_time
         FROM     xxwv.xxwv_hsum_info_reports
    SELECT     start_time
    ,     end_time
    ,     (end_time - start_time) * 24 * 60     AS duration_minutes
    FROM     got_times
    ;When you run the two different (but very similar) to get the two times, you have two different WHERE clauses. You can combine those two similar queries into one, but whatever WHERE clause you have will apply to the whole query. Whenever you wish you could apply a WHERE clause just to one column, think of CASE instead.

Maybe you are looking for