Use of analytical columns?

In general, this kind of thing is easily obtained in Excel where you can calculate values in a column of output based on the input values. I need to do this in the reports. I use (generator of reports version 6.0.8.27.0) reports 6i


I have a relatively simple question where I'm out of values (heads) and then I need to display the sum on the next line. Let me explain with an example:

ID Start Date End Date column 1 column 2

=============================================

1 1 JANUARY 2010 TO 30 JUNE 2010 120 0

2 1 JULY 2010 TO 31 DECEMBER 2010 200 120

3. ON JANUARY 1, 2011 30 JUNE 2011 115 320

4 1ST JULY 2011 31 DECEMBER 2012 300 435

5 1 JANUARY 2013 TO 30 JUNE 2013 100 735

As you can see that the 2 column is derived by adding the previous values in column 1 and appear on the next line.

So for ID = 4, column 2 = 120 + 200 + 115 = 435 and ID = 5, column 2 = 120 + 200 + 115 + 300 = 735.

When I use columns in summary, I do not get the desired result.

I could technically create a formula column and a column of support in place and re - question results but I was hoping to avoid another SQL when the data has already been retrieved. Any ideas or pointers would be greatly appreciated!

Thank you

Hello

I think I can satisfy u

Download the rdf (6i)

https://www.Zeta-Uploader.com/1236837069

This URL is valid until Tuesday, June 25, 2013

Thank you

Alexander simonnet

Tags: Oracle Development

Similar Questions

  • Using the analytic function

    Oracle 11g Release 2

    I'm assuming that the best solution is the use of analytical functions.

    create table test3
    ( part_type_id  varchar2(50)
    ,group_id      number
    ,part_desc_id  number
    ,part_cmt      varchar2(50)
    )
    /
    
    insert into test3 values( 'ABC123',1,10,'comment1');
    insert into test3 values( 'ABC123',1,10,'comment2');
    insert into test3 values( 'ABC123',2,15,'comment1');
    insert into test3 values( 'ABC123',2,15,'comment2');
    insert into test3 values( 'EFG123',25,75,'comment3');
    insert into test3 values( 'EFG123',25,75,'comment4');
    insert into test3 values( 'EFG123',25,75,'comment5');
    insert into test3 values( 'XYZ123',1,10,'comment6');
    insert into test3 values( 'XYZ123',2,15,'comment7');
    commit;
    
    select * from test3;
    
    PART_TYPE_ID           GROUP_ID PART_DESC_ID PART_CMT
    -------------------- ---------- ------------ --------------------
    ABC123                        1           10 comment1
    ABC123                        1           10 comment2
    ABC123                        2           15 comment1
    ABC123                        2           15 comment2
    EDG123                        25          75 comment3
    EDG123                        25          75 comment4
    EDG123                        25          75 comment5
    XYZ123                        1           10 comment6
    XYZ123                        2           15 comment7
    
    9 rows selected.
    
    Desired output:
    
    PART_TYPE_ID           GROUP_ID PART_DESC_ID PART_CMT
    -------------------- ---------- ------------ --------------------
    ABC123                        1           10 comment1 
    ABC123                        2           15 comment1
    XYZ123                        1           10 comment1
    XYZ123                        2           15 comment2
    
    RULE: where one part_type_id has multiple (2 or more distinct combinations) of group_id/part_desc_id
    
    NOTE: There are about 12 columns in the table, for brevity I only included 4.
    
    
    
    

    Post edited by: orclrunner was updated desired output and rule

    Hello

    Here's one way:

    WITH got_d_count AS

    (

    SELECT part_type_id, group_id, part_desc_id

    MIN (part_cmt) AS min_part_cmt

    COUNT AS d_count (*) OVER (PARTITION BY part_type_id)

    OF test3

    GROUP BY part_type_id, group_id, part_desc_id

    )

    SELECT DISTINCT

    group_id, part_desc_id, part_type_id, min_part_cmt

    OF got_d_count

    WHERE d_count > 1

    ;

    Output:

    GROUP_ID PART_DESC_ID MIN_PART_CMT PART_TYPE_ID

    ------------ ---------- ------------ ------------

    ABC123 1 10 comment1

    ABC123 2 15 comment1

    XYZ123 1 10 comment6

    XYZ123 2 15 comment7

    Analytical functions, such as the COUNTY and MIN, many global versions, in addition, it can give the same results.  Use the analytical versions when each row of output corresponds to exactly 1 row of input and the aggregate and GROUP BY version when each line of output corresponds to a group of lines 1 or more input.  In this issue, each line of output appears to be a group of input lines having the same group_id, part_type_id, and part_desc_id (I'm guessing just, this only has never stated), so I used GROUP BY to get 1 row of output for every input lines.

  • Value of the analytical column changing to NULL in RDF

    Hello everyone.

    For the column in the existing query in RDF, which is used by one of the analytical column as a source.
    If the request is get changed according to the requirement of bussiness, the source of the analytical column evolves with the NULL value.

    Is there a way do not allow this change in RDF. Because many changes of the query are done. And it consumes a lot of time to change sources of the used analytical columns.

    Appreciate your help.

    Thank you.

    In general, this shouldn't happen. You defined ALIAS' are appropriate for the column that inspired the summaryitems?

  • SQL using the analytic function


    Hi all

    I want a help in the creation of my SQL query to retrieve the data described below:

    I have a test of sample table containing data as below:

    State ID Desc

    MICHAEL 1 T1

    ACTIVE 2 T2

    T3 3 SUCCESS

    DISABLE THE T4 4

    The thing I want to do is to select all the lines with an ACTIVE status in the table but is there is no ACTIVE status, my request will give me the last line with MICHAEL status.

    I can do this in a single request by using the analytical function for example, if yes can yiu help me on the request of unpacking.

    Kind regards

    Raluce

    Something like that?

    I had to fix it.

    with testdata until)
    Select 1 id, "T1" dsc "DISABLED" status of Union double all the
    Select 2 id, 'T2' dsc, the status "ACTIVE" of all the double union
    Select id 3, "T3" dsc, the status of 'SUCCESS' of all the double union
    Select 4 id, "T4" dsc "DISABLED" status of double
    )

    Select
    ID
    dsc
    status
    of testdata
    where
    status =
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then 'ACTIVE '.
    Another 'DISABLED '.
    end
    and)
    ID in (select id from testdata where status = ' ACTIVE')
    or
    ID = (select max (id) in testdata when status = 'DISABLED')
    )

    STATE ID DSC

    '2' 'T2' 'ACTIVE '.

    Maybe it's more efficient

    Select
    ID
    dsc
    status
    of testdata
    where
    status =
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then 'ACTIVE '.
    Another 'DISABLED '.
    end
    and
    ID =)
    -case when (select count (*) in testdata where status = 'ACTIVE') > 0
    then id
    on the other
    (select max (id) in testdata when status = 'DISABLED')
    end
    )

    Post edited by: correction of chris227

    Post edited by: chris227
    extended

  • Adding two analytical columns?

    Hi guys, another quick question. I have two analytical columns in my report. Is it possible to add up the total of these two columns?

    Thank you.

    Create a formula column

    and PL / formula SQL

    Add these two columns

    return: CS_COLUMN1 +: CS_COLUMN2;

  • maximum number of characters used in a column

    Hi all
    Suppose I have a table named employee with two fileds (Emp_id and name)
    I need the query to find the maximum number of characters used in the column name until now.

    CNA anyone help me.

    combine the MAX and LENGTH

    as in:

    SQL> select max (length (ename))
      2    from emp
      3  ;
    
    MAX(LENGTH(ENAME))
    ------------------
                     6
    
    SQL> 
    
  • By using the analytical function to sort without showing this column in the result.

    Hello

    We use the Oracle 11.2

    How to use Oracle Analytics to sort the output of a query without showing this column in the result?

    Here's my query:

    Select distinct nvl(SRC_CHR_NM,'0') | » #'|| NVL(EXPL_SRC,'0') | » #'|| NVL(DIM_NM,'0') | » #'|| NVL(DIM_CHR_NM,'0') | » #'|| NVL(DIM_CHR_ABR,'0') | » #'||

    Decode (InStr (NVL(SRC_COL_NM,'0'), 'trim ('),'1 ', Replace (NVL(SRC_COL_NM,'0'),'trim (',' trim(PRM_DTL.'), '0',' PRM_DTL.)))) » || NVL(SRC_COL_NM,'0')) AS ALLOFIT,

    DIM_NM

    from EXPL_CONFIG where SBJ_AREA_CD = 'PRMDTL. '

    I want to use analytical to sort by DIM_NM but I do not want to show. I want to just just the ALLOFIT column to show in the output.

    Something like "row_number() over (order by DIM_NM desc).

    Thank you!

    Hello

    If you SELECT SEPARATE, then you can only ORDER OF things in the SELECT clause. (Do you really need to do SELECT DISTINCT?  Often, it's just an inefficient way to remove the lines that do not need to be there at all).

    Move making the SELECT DISTINCT in a subquery and make the ORDER BY (and nothing else) in the main query.

    I hope that answers your question.

    If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • Using the analytical function.

    Hello

    I have this scenario.
    with t as 
    (
    select 21009 item_id,9 primary_available,450 max_qty,100 bulk_available,12122 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,2775 bulk_available,8704 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,524 bulk_available,15614 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,3300 bulk_available,15654 bulk_locator_id
    from dual)
    select  t.* from t;
    We have two locations for a given item_id. Primary and in bulk.

    I'm trying to get a select statement out of this point of view, where I will be restock the primary AMOUNT of sites in bulk, BUT the smaller bulk first. Once she gets up, I shouldn't take more product.

    There is an analytic function that would do this?

    That's the max I could come up with.
    with t as 
    (
    select 21009 item_id,9 primary_available,450 max_qty,100 bulk_available,12122 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,2775 bulk_available,8704 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,524 bulk_available,15614 bulk_locator_id 
    from dual union all
    select 21009 item_id,9 primary_available,450 max_qty,3300 bulk_available,15654 bulk_locator_id
    from dual)
    select  t.*, max_qty -
                   (primary_available + SUM(bulk_available)
                    over(PARTITION BY item_id ORDER BY bulk_available)) replen_this_much 
                    from t;
    So, in this scenario, I want to replen bulk_locator_id 100 ' 12122 'and ' 15614 bulk_locator_id 341'. That's all. ZERO of the other rentals (bulk_locator_id). If the question is not clear, please let me know.

    Published by: RPuttagunta on September 11, 2009 16:23

    Hello

    Thanks for posting the sample data.
    It would be useful that you also posted the output you want. Is this?

    .                                 BULK_         REPLEN_
    ITEM_ PRIMARY_   MAX_  BULK_      LOCATOR_        THIS_
    ID    AVAILABLE  QTY   AVAILABLE  ID               MUCH
    ----- ---------- ----- ---------- ---------- ----------
    21009 9          450   100        12122             100
    21009 9          450   524        15614             341
    21009 9          450   2775       8704                0
    21009 9          450   3300       15654               0
    

    If so, you can get to this:

    SELECT       t.*
    ,       GREATEST ( 0
                 , LEAST ( TO_NUMBER (bulk_available)
                         , TO_NUMBER (max_qty)
                        - ( TO_NUMBER (primary_available)
                          + NVL ( SUM (TO_NUMBER (bulk_available))
                                  OVER ( PARTITION BY  item_id
                                         ORDER BY      TO_NUMBER (bulk_available)
                                   ROWS BETWEEN  UNBOUNDED PRECEDING
                                     AND      1           PRECEDING
                                 )
                             , 0
                             )
                          )
                      )
                 ) AS replen_this_much
    FROM       t
    ORDER BY  item_id
    ,            TO_NUMBER (bulk_available)
    ;
    

    You should really store your numbers in NUMBER of columns.

    You essentially posted all what you need analytical functions. The problem was just wrapping this analytical function (or something very close to it) and LESS and more GRAND, so that the replen_this_much column is always between 0 and TO_NUMBER (bulk_available).

  • Bulk collect using some different column insert a table

    Hi all

    I gave an example of emp table in my original 100 million table record are I need to change group (IE deptno) 10 to 20 copy the same records

    about these codes, I get exception

    ORA-06550: line 11, column 53:

    PLS-00386: concordance that is 'EMP_TAB' between FETCH cursor and IN variables of type

    can help me please for these

    declare

    type row_tab is table emp % rowtype

    INDEX BY PLS_INTEGER;

    emp_tab row_tab;

    cursor cur_emp is select ENAME, 20 DEPTNO, HIREDATE, emp COMM EMPNO;

    Start

    Open cur_emp;

    loop

    Cur_emp fetch bulk collect in the limit emp_tab 2000;

    ForAll i in 1.emp_tab. COUNTY

    Insert / * + APPEND * / into emp (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)

    values (emp_tab (i). EMPNO, emp_tab (i). Ename, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.) ;

    When the output cur_emp % notfound;

    END LOOP;

    close cur_emp;

    end;

    /

    Thank you

    VSM

    I use the user define the type of record to over come error

    declare

    type emp_rt is record (empno, ename emp.ename%type,deptno NUMBER (2) emp.empno%type, hiredate emp.hiredate%type,comm emp.comm%type);

    TYPE row_type IS the emp_rt INDEX TABLE OF pls_integer;

    emp_tab row_type;

    cursor cur_emp is select empno, ename, 20 deptno, hiredate, comm from emp where deptno = 10;

    Start

    Open cur_emp;

    loop

    Cur_emp fetch bulk collect in the emp_tab limit 2;

    ForAll i in 1.emp_tab. COUNTY

    Insert / * + APPEND * / into EMP (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)

    values (emp_tab (i). EMPNO, emp_tab (i). ENAME, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.)

    ;

    When the output cur_emp % notfound;

    END LOOP;

    close cur_emp;

    end;

    /

    records are successful inserted, I do not know is not the right approach for 100 million documents?

    Thank you

    VM

  • Highlighted value in table reports using html changes column width

    I use basic highlighting using raw html SQL to select a column. However, I noticed that the column width becomes very large compared to the displayed value, maybe there also took html into consideration for length? Not sure if there is a problem with the grid itself.

    for example this piece of code, see the difference in width of columns status and status_1... Ideally I would like to see the two columns of the same size as status_1.

    select case when BP.STATUS = 'LOCKED' then '<html><body><strong><font color="blue">' || BP.STATUS || '</font></string></body></html>' 
    when bp.status = 'COMPLETED' then '<html><body><strong><font color="green">' || bp.status || '</font></string></body></html>'
    when BP.STATUS = 'PROCESSING' then '<html><body><strong><font color="orange">' || BP.STATUS || '</font></string></body></html>' end STATUS
    ,BP.STATUS STATUS
    from (select 'COMPLETED' status from dual union all select 'PROCESSING' from dual union all  select 'LOCKED' from dual) bp ;
    

    Developer SQL 4.1.1

    It's an unfortunate side effect

    We could / should have code in there to set the width based on the vs html rendering the actual html source code

    but it's a development request

  • Nth salary using the analytic function

    I use under function to calculate second highest with empno and deptno salary.

    Is it possible to get the same result with another query without using Assembly only analytical functions condition.using and windows function is possible to get the desired output?

    SELECT e.empno,

    e.DEPTNO,

    tmp. SAL as second_higher_salary

    FROM emp e,.

    (SELECT Empno,

    DEPTNO,

    SAL,

    DENSE_RANK() (PARTITION BY deptno ORDER of sal) AS rnk

    WCP

    ) tmp

    WHERE tmp.deptno = e.deptno

    and tmp.rnk = 2

    EMPNO DEPTNO SAL

    ---------- ---------- ----------

    7934 10 2450

    7782 10 2450

    7839 10 2450

    7876 20 1100

    7369 20 1100

    7902 20 1100

    7788 20 1100

    7566 20 1100

    7900 30 1250

    7844 30 1250

    7654 30 1250

    7521 30 1250

    7499 30 1250

    7698 30 1250

    7900 30 1250

    7844 30 1250

    7654 30 1250

    7521 30 1250

    7499 30 1250

    7698 30 1250

    Here's my solution:

    Select empno,

    DEPTNO,

    FIRST_VALUE (sal) (PARTITION BY deptno ORDER by sal desc)

    de)

    SELECT EmpNo,

    DEPTNO,

    Decode (DENSE_RANK () OVER (PARTITION BY deptno order by sal desc), 1,-sal, sal) sal

    WCP

    )

    /

    EMPNO DEPTNO FIRST_VALUE (SAL) OVER (PARTITIONBYDEPTNOORDERBYSALDESC)

    ---------- ---------- -----------------------------------------------------

      7782 10 2450
      7934 10 2450
      7839 10 2450
      7566 20 2975
      7876 20 2975
      7369 20 2975
      7788 20 2975
      7902 20 2975
      7499 30 1600
      7844 30 1600
      7654 30 1600
      7521 30 1600
      7900 30 1600
      7698 30 1600
  • need to get only one line when you use between (date columns)

    Hi all

    create the table SAMPLE_ITEMS

    (ITEM_NO, varchar2 (10))

    Date DELIVERY_DATE,

    Number of QTY_SUM1

    Number of QTY_SUM2

    Number ITEM_QTY,

    Number ORDER_QTY,

    Number ITEM_AMOUNT,

    Number of SALES_AMOUNT

    );

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 04/2014 ',-88, 0,475,262,-123.45,-1188);

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 05/2014 ', 0, - 122, 475, 262, - 10.234,-1647);

    insert into SAMPLE_ITEMS values ('AAA', ' 16 / 06/2014. ', 0, 0,475,262,-80.59,-135);

    insert into SAMPLE_ITEMS values ('AAA', 19 December 2014 ', 0, 0,475,262,-42.29,-67.5);

    Setting out with my own query,

    ITEM_NOTRUNC (DELIVERY_DATE)QTY_SUM1QTY_SUM2ITEM_QTYORDER_QTYITEM_AMOUNTSALES_AMOUNT
    AAA28/04/2014-880475262-123.45-1188
    AAA28/05/20140-122475262-10.234-1647
    AAA16/06/201400475262-80.59-135
    AAA19/12/201400475262-42.29-67.5

    Every time I question as code

    Select * from SAMPLE_ITEMS

    where DELIVERY_DATE between April 28, 2014 ' and 19 December 2014 '-> they must pass as a parameter

    I need to get only one line

    AAA-88-122475262-256.564-3037.5

    Database 11.2.0.1.0

    Note; Please do not use MAX for Date and do not want to display Date columns in the result

    Note 1: I want to choose DELIVERY_DATE in select it also and only get a line like above the expected result

    SELECT item_no

    SUM (qty_sum1),

    SUM (qty_sum2),

    SUM (DISTINCT item_qty),

    SUM (DISTINCT order_qty),

    SUM (item_amount),

    SUM (sales_amount)

    OF SAMPLE_ITEMS

    WHERE the DELIVERY_DATE BETWEEN TO_DATE (28 April 2014 ', "dd/mm/yyyy")

    AND TO_DATE (19 December 2014 ', "dd/mm/yyyy")

    GROUP BY item_no;

    I will get

    ITEM_NO Trunc (DELIVERY_DATE) QTY_SUM1 QTY_SUM2 ITEM_QTY    ORDER_QTY TTEM_AMOUNT SALES_AMOUNT        

    AAA             12/19/2014                         -88                 -122                475                262                       -256.564              -3037.5

    OK fine, I want to choose DELIVERY_DATE as if so I'll have all the lines, but I want to only show one as shown above

    Because I do report discoverer in Oracle Apps, without taking the DELIVERY_DATE of the select query, it is not possible to move the date as a parameter

    Can you please help me how to do this?

    Thank you

    Post edited by: Rajesh123 NOTE added in the body of the Message

    Post edited by: added test Rajesh123 messages

    Maybe you want a single line in all cases

    Select si.item_no,

    start_date min (d.start_date),

    min (d.end_date) end_date,

    min (si.qty_sum1) qty_sum1,

    min (si.qty_sum2) qty_sum2,

    min (si.item_qty) item_qty,

    min (si.order_qty) order_qty,

    Sum (si.item_amount) item_amount,

    Sum (if. Sales_Amount) sales_amount

    of (start_date select to_date(:date_from,'dd-MON-yyyy'))

    to_date(:date_to,'dd-mon-yyyy') end_date

    of the double

    ) d

    left outer join

    TR sample_items

    on the si.delivery_date between d.start_date and d.end_date

    Group of item_no

    ITEM_NO START_DATE END_DATE QTY_SUM1 QTY_SUM2 ITEM_QTY ORDER_QTY ITEM_AMOUNT SALES_AMOUNT
    - 01/01/1900 31/12/2000 - - - - - -

    Concerning

    Etbin

  • Oracle: Analytics: how to sort by using a few column names

    I have a request that is the same as the lower.

    select organization_name, is_manager, is_vendor, is_engineer from table_org_roles;

    The example data:

    organization_name|is_manager|is_vendor|is_engineer

    ---------------------------------------------------

    Org_A   |Yes   |No   |No

    Org_B   |No   |Yes   |No

    Org_C   |No   |No   |Yes

    However I wanted to do a SQL query that is classified by her mounted the role name that is the name of the column. How can I make query that is displayed as below:

    Roles(ASC) | Organization

    -------------------------

    is_engineer| Org_C

    is_manager | Org_A

    is_vendor  | Org_B

    Is it possible to make this query using Analytics? Thank you much in advance.

    No required Analytics:

    SELECT "is_engineer" roles, OrganizationName

    OF table_org_roles

    WHERE is_engineer = 'Yes '.

    UNION ALL

    SELECT 'is_manager', OrganizationName

    OF table_org_roles

    WHERE is_manager = 'Yes '.

    UNION ALL

    SELECT 'is_vendor', OrganizationName

    OF table_org_roles

    WHERE is_vendor = 'Yes '.

    ORDER BY 1

  • using line as column names

    All,

    I have two tables like questions_tbl table and response_tbl table I want to use queries the table in question (q1, q2, g3 etc.) as title/names of columns and the corresponding answers in the table response_tbl for this question as column values

    questions_tbl (id, question_code, q1, q2, q3)

    responses_tbl (id, question_code, resp1, resp2, resp3)

    logged in as questions_tbl.question_code = responses_tbl.question_code IE 1-to-many

    example of report,

    What is your favorite car?                 What is xxxxxx?                     What is your best pet?

    ========================   ======================  ========================

    ford                                             laptop                                     dog

    Chevy                                         cellphone                                dove

    vw                                              ipod                                        dolphin

    How can I write this in sql/plsql to achieve this result?

    Oracle 11g 2

    Thank you.

    create the table questions_tbl as

    Select 1 id, 'T1' question_code, "what is your favorite car?" question of all the double union

    Select 2, 'q2', "what is your favorite device?" of all the double union

    Select 3, "q3", 'what is your favorite animal?' in union double all the

    Select 4, 'T4', "what is your favorite plant?" of all the double union

    Select 5, 'q5', "what is your favorite hamburger?" of the double

    create the table responses_tbl as

    Select 1 id, 'T1' question_code, 'Ford' Union response double all the

    Select 2, 'T1', 'Chevy' from dual union all

    Select 3, 'T1', 'VW' from dual union all

    Select option 4, "T2", "notebook" of the dual union all

    Select 5, 'T2', 'cell phone' from dual union all

    Select 6, 'T2', 'i - pod' from dual union all

    Select 7, "T2", "i - pad' from dual union all

    Select 8, "T2", "toothbrush" dual Union all

    Select 9, "q3", "dog" of all the double union

    10. Select, "q3", "plunged" the dual union all

    Select 11, "q3", "Dolphin" dual union all

    Order 12, "q3", "cat" dual union all

    Select 13, 'q5', 'Ham' from dual union all

    Select 14, 'q5', 'cheese' from dual union all

    Select 15, 'q5', 'fish' of all the double union

    Select 16, 'q5', 'chicken' of the double

    create or replace function report_query (no_of_columns in number) return varchar2 is

    sql_result varchar2 (4000): = q'[select id,

    0 rn,

    Upper (question) text

    of questions_tbl

    Union of all the

    Select q.id,

    ROW_NUMBER() over (partition by order q.question_code by r.id) rn,

    r.Response text

    of questions_tbl q,.

    responses_tbl r

    where q.question_code = r.question_code

    order by id, rn

    ]';

    sql_x varchar2 (4000): = ";

    sql_y varchar2 (4000): = ";

    sql_1 varchar2 (4000): = q'[select row_is,

    RN,

    ]';

    sql_2 varchar2 (4000): = q'[max (c1) c1,

    ]';

    sql_3 varchar2 (4000): = q'[from (select ceil (id /: columns) row_is,)]

    RN,

    ]';

    sql_4 varchar2 (4000): = q'[case when mod(id,:columns) = 1 then c1, end of text,

    ]';

    sql_5 varchar2 (4000): = q'[Correction (select id,

    0 rn,

    Upper (question) text

    of questions_tbl

    Union of all the

    Select q.id,

    ROW_NUMBER() over (partition by order q.question_code by r.id) rn,

    r.Response text

    of questions_tbl q,.

    responses_tbl r

    where q.question_code = r.question_code

    )

    )

    Group of row_is, rn

    order of row_is, rn

    ]';

    Start

    If no_of_columns > 1 then

    because me in 1... no_of_columns

    loop

    sql_x: = sql_x | Replace (sql_2, '1', to_char (i));

    sql_y: = sql_y | Replace (sql_4, '1', to_char (i));

    end loop;

    sql_x: = replace (sql_x, to_char (no_of_columns): ',', to_char (no_of_columns));

    sql_y: = replace (sql_y, to_char (no_of_columns): ',', to_char (no_of_columns));

    sql_y: = replace (sql_y, '=' | to_char (no_of_columns), '= 0');

    sql_result: = replace(sql_1|| sql_x || sql_3 || sql_y || sql_5,':columns',to_char(no_of_columns));)

    end if;

    Return sql_result;

    end;

    Select report_query (3) double T3

    Q3
    Select rn, max c1, c2 max (c2), row_is, max (c3) c3 (c1) from (select ceil(id / 3) row_is, rn, case when mod(id,3) = 1 then text end c1, case when mod(id,3) = 2 then text end c2, case when mod(id,3) = 0 then the text end c3 from (select id, 0 rn) ((, text of upper (question) of questions_tbl union q.id select all the row_number() over (partition by order q.question_code by r.id) rn, text of r.response of q, r responses_tbl questions_tbl where q.question_code = r.question_code)) Group of row_is, sort row_is, rn rn

    Select rn, max c1, c2 max (c2), row_is, max (c3) c3 (c1) from (select ceil(id / 3) row_is, rn, case when mod(id,3) = 1 then text end c1, case when mod(id,3) = 2 then text end c2, case when mod(id,3) = 0 then the text end c3 from (select id, 0 rn) ((, text of upper (question) of questions_tbl union q.id select all the row_number() over (partition by order q.question_code by r.id) rn, text of r.response of q, r responses_tbl questions_tbl where q.question_code = r.question_code)) Group of row_is, sort row_is, rn rn

    ROW_IS RN C1 C2 C3
    1 0 WHAT'S YOUR CAR FAVORITE? WHAT IS YOUR FAVORITE? WHAT IS YOUR ANIMAL FAVORITE?
    1 1 Ford laptop dog
    1 2 Chevy cell phone Dove
    1 3 VW i pod Dolphin
    1 4 - i pad CAT
    1 5 - toothbrush -
    2 0 WHAT IS YOUR FAVORITE? WHAT IS YOUR BURGER FAVORITE? -
    2 1 - Ham -
    2 2 - cheese -
    2 3 - fish -
    2 4 - chicken -

    Select report_query (2) double T2

    Q2
    Select row_is, rn, max (c1) c1, c2 from max (c2) (select ceil(id / 2) row_is, rn, case when mod(id,2) = 1 then text end c1, case when mod(id,2) = 0 then text end c2 from (select id, 0 rn, upper (question) of questions_tbl union q.id text select all, row_number() on rn (partition by order q.question_code by r.id) questions_tbl r.response text q) ((, r responses_tbl where q.question_code = r.question_code)) Group of row_is, sort row_is, rn rn

    Select row_is, rn, max (c1) c1, c2 from max (c2) (select ceil(id / 2) row_is, rn, case when mod(id,2) = 1 then text end c1, case when mod(id,2) = 0 then text end c2 from (select id, 0 rn, upper (question) of questions_tbl union q.id text select all, row_number() on rn (partition by order q.question_code by r.id) questions_tbl r.response text q) ((, r responses_tbl where q.question_code = r.question_code)) Group of row_is, sort row_is, rn rn

    ROW_IS RN C1 C2
    1 0 WHAT'S YOUR CAR FAVORITE? WHAT IS YOUR FAVORITE?
    1 1 Ford laptop
    1 2 Chevy cell phone
    1 3 VW i pod
    1 4 - i pad
    1 5 - toothbrush
    2 0 WHAT IS YOUR ANIMAL FAVORITE? WHAT IS YOUR FAVORITE?
    2 1 dog -
    2 2 Dove -
    2 3 Dolphin -
    2 4 CAT -
    3 0 WHAT IS YOUR BURGER FAVORITE? -
    3 1 Ham -
    3 2 cheese -
    3 3 fish -
    3 4 chicken -

    You said that it is a report

    Concerning

    Etbin

  • How to deploy a different presentation of Services, plug-ins using the analytical file

    How to deploy another presentation Services plugin using the file analytics.ear

    Thank you

    Your question is not clear you'll correct me if I'm wrong...
    'Presentation plug-in Services' are used to redirect all the analytical application to actual box where BI and saw or has seen the service is running or when the machine webcat is hosted...

    'analytics.ear' deploy us using oc4j em (ex: 10 g) default sound for "analytical".

    You want to deploy another file "analytics.ear" with a different name on the same Web server as oc4j? use the em, then go to the Application tab-> deploy.

    If brand pls help

    Published by: Srini VIEREN on 13 December 2012 06:12

Maybe you are looking for