Pivot sql

Hi,
ID Contract_Year
  type1Fee 1
type1Fee 2 type1Fee 3
  type2Year1 type2Year2
type2Year3
1 2015
$1.50 $1.50 $1.50
$2.00 $2.00
$2.00
this is my SOURCE DATA, AND i am trying to get in this model
id  CONTRACT_yr TYPE
year1    year2       year3
1 2015
type1 1.5
1.5 1.5
2 2015
type2 2.0
2.0 2.0
Please help

Here is the Create table scripts for the above question:
CREATE TABLE fee
Id int
,contracy_yr
int
,type1fee1
money
,type1fee2
money
,type1fee3   money
,type2fee1
money
,type2fee2
money
,type2fee3
money
INSERT INTO fee 
SELECT 
1,
2015,
$1.5,
$1.5,
$1.5,
$2.0,
$2.0,
$2.0
SELECT * FROM fee
--Expected Output:
SELECT 
1 AS id, 2015 AS C_year, 'type1' AS Type,$1.5 AS Fee1,$1.5 AS Fee2,$1.5 AS Fee3
UNION
2 AS id, 2015 AS C_year, 'type2' AS Type,$2.0 AS Fee1,$2.0 AS Fee2,$2.0 AS Fee3

Similar Messages

  • PIVOT sql help

    Hi again
    I need some PIVOT sql help
    In this query:
    SELECT
    SUM([RATES]) as RATES
    ,SUM([CONVERSION])as CONVERSION
    FROM REPORTING
    outputs
    RATES CONVERSION
    23 234
    How would change this query to display a table like:
    Name Amount
    RATES 23
    CONVERSION 234
    Keep up the good work !

    nikos101 wrote:
    > How would change this query to display a table like:
    Do you *HAVE* to change the query... you could just display
    it in the
    desired format if that it the ultimate and only goal.
    <table>
    <tr>
    <td>name</td>
    <td>amount</td>
    </tr>
    <cfoutput query="sumQry">
    <tr><td>Rates</td><td>#rates#</td></tr>
    <tr><td>Conversion</td><td>#conversion#</td></tr>
    </cfoutput>
    </table>

  • Pivot sql year/month/category

    Need help with this :
    Requirement : need to pivot data based on year, month and display the sales correctly. if the data for any month does not exist that month shoudl not appear in the results.
    Sample data :
    --DROP TABLE APPS.TEST_OM_V CASCADE CONSTRAINTS;
    CREATE TABLE APPS.TEST_OM_V
    TAX_CATEGORY VARCHAR2(250 BYTE),
    SHIP_FROM_ORG_NAME VARCHAR2(100 BYTE),
    SCHEDULE_SHIP_DATE DATE,
    UNIT_SELLING_PRICE NUMBER,
    ORDERED_QUANTITY NUMBER,
    INVOICED_SALES NUMBER
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('Operating Supplies', 'DC FONT (FONT-120)', TO_DATE('02/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 12, 13,
    23);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('09/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 90, 7,
    23.34);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('COFFEE', 'DC Florida (FLO-180)', TO_DATE('09/14/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 8,
    75);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('10/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
    100.11);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('08/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
    75);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('Operating Supplies', 'DC DIST (DIS-130)', TO_DATE('10/21/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 12, 13,
    23);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('08/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
    75);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('Operating Supplies', 'DC CANADA (CAN-180)', TO_DATE('01/02/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 23, 1,
    45);
    Insert into APPS.TEST_OM_V
    (TAX_CATEGORY,
    SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
    Values
    ('Operating Supplies', 'DC PACK (PK-160)', NULL, 1, 2,
    1);
    COMMIT;
    Expected result , or anything close to this :
                                                                                2011                                     2012
                                                                   AUG      SEP          OCT         JAN   FEB      UNSCHEDULED
      COFFEE
                                    DC CANADA (CAN-180)          -30         606.66    -40.11         0          0          0
                                    DC Florida (FLO-180)          0           165         0           0          0          0
    Operating Supplies
                                    DC CANADA (CAN-180)           0           0            0         -22        0          0
                                    DC DIST (DIS-130)             0           0            133         0         0          0
                                    DC FONT (FONT-120)            0           0            0           0         133        0
                                    DC PACK (PK-160)              0           0            0           0          0           1 I tried grouping and summing and then lost my way...
    select TAX_CATEGORY, SHIP_FROM_ORG_NAME, nvl(TO_CHAR((SCHEDULE_SHIP_DATE), 'MM/YYYY'),'N/A') SCHEDULE_SHIP_DATE,
    sum((unit_selling_price * ORDERED_QUANTITY ) - nvl(INVOICED_SALES,0)) CARRYOVER
    from XXCNC.TEST_OM_V where 1=1
    group by TAX_CATEGORY, SHIP_FROM_ORG_NAME,nvl(TO_CHAR((SCHEDULE_SHIP_DATE), 'MM/YYYY'),'N/A')
    order by 1,2,3;
    Thanks for your help in advance.
    J

    Like this?:
    SQL> set num 6 lin 120 trims on
    SQL> col tax_category for a20
    SQL> col SHIP_FROM_ORG_NAME for a32
    SQL> break on tax_category
    SQL> SELECT *
      2  FROM (SELECT tax_category,
      3               ship_from_org_name,
      4               NVL( TO_CHAR( ( schedule_ship_date ), 'MM/YYYY' ), 'N/A' ) schedule_ship_date,
      5               ( unit_selling_price * ordered_quantity ) - NVL( invoiced_sales, 0 ) carryover
      6        FROM test_om_v) PIVOT (SUM( carryover )
      7                        FOR schedule_ship_date
      8                        IN  ('08/2011' AS "Aug'11",
      9                            '09/2011' AS "Sep'11",
    10                            '10/2011' AS "Oct'11",
    11                            '11/2011' AS "Nov'11",
    12                            '12/2011' AS "Dec'11",
    13                            '01/2012' AS "Jan'12",
    14                            '02/2012' AS "Feb'12",
    15                            'N/A' AS "UNSCHEDULED"))
    16  ORDER BY 1, 2, 3
    17  /
    TAX_CATEGORY         SHIP_FROM_ORG_NAME               Aug'11 Sep'11 Oct'11 Nov'11 Dec'11 Jan'12 Feb'12 UNSCHEDULED
    COFFEE               DC CANADA (CAN-180)                 -30 606.66 -40.11
                         DC Florida (FLO-180)                       165
    Operating Supplies   DC CANADA (CAN-180)                                                    -22
                         DC DIST (DIS-130)                                 133
                         DC FONT (FONT-120)                                                            133
                         DC PACK (PK-160)                                                                            1
    6 rows selected.:p
    Edited by: LKBrwn_DBA on Dec 16, 2011 12:18 PM

  • Pivot SQL --Pls advise

    Select distinct a.forename as "Name",
    a.surname as "Surname",
    a.forename ||''||a.surname as "Fullname",
    b.ancestors as "Ancestors",
    Other columns ..
    from table1 a,table2 b,table3 c,table4 d...
    where a.col1 =b.col1 and ..(other conditions)
    Output is as follows:
    Forename1 Surname1 Fullname1 Ancestor1 Other columns
    Forename1 Surname1 Fullname1 Ancestor2 Other columns
    Forename1 Surname1 Fullname1 Ancestor3 Other columns
    Forename1 Surname1 Fullname1 Ancestor4 Other columns
    required output is
    Forename1 Surname1 Fullname1 Ancestor1/Ancestor2/Ancestor3/Ancestor4 Other columns
    I am new to Pivot concept and never used it.
    Please help in modifying query.
    thanks in advance.

    The ability to generalise from the specific - in this case the ability to figure out a solution to your problem by examining a solution to someone else's similar problem - is vital in the world of IT.
    How about developing your skills in that area by searching the forum for PIVOT or rows+to+columns and see what you can come up with? Even if you can't quite figure it out, we'll be happy to help you over the finish line once you post your query. I suspect that SYS_CONNECT_BY_PATH is actually going to be worth investigating rather than pivot, given your description of the desired output.

  • Help with SQL to Pivot SQL

    I have requirment to build the SQL to Merge rows value to a single value.
    Here is the Data
    TABLE_A
    ID SEQ MESG
    1 1 MSG1
    1 2 MSG2
    2 1 MSG1
    3 1 MSG1
    3 2 MSG2
    3 3 MSG3
    I need output as
    ID MSG
    1 MSG1 MSG2
    2 MSG1
    3 MSG1 MSG2 MSG3

    Create function like below:
    CREATE OR REPLACE  FUNCTION rowtocol( p_slct IN VARCHAR2, p_dlmtr IN VARCHAR2 DEFAULT ',' ) RETURN VARCHAR2
    AUTHID CURRENT_USER AS
        TYPE c_refcur IS REF CURSOR;
        lc_str VARCHAR2(4000);
        lc_colval VARCHAR2(4000);
        c_dummy c_refcur;
        l number;
    BEGIN
        OPEN c_dummy FOR p_slct;
        LOOP
        FETCH c_dummy INTO lc_colval;
        EXIT WHEN c_dummy%NOTFOUND;
        lc_str := lc_str || p_dlmtr || lc_colval;
        END LOOP;
        CLOSE c_dummy;
        RETURN SUBSTR(lc_str,2);
           EXCEPTION
           WHEN OTHERS THEN
              lc_str := SQLERRM;
              IF c_dummy%ISOPEN THEN
              CLOSE c_dummy;
              END IF;
           RETURN lc_str;
    END;
    /And print result like :
       SELECT DISTINCT  a.job,
          rowtocol(  'SELECT ename  FROM emp
                           WHERE
                           job = ' || '''' || a.job || '''' || ' ORDER BY ename'
         AS Employees
        FROM emp;

  • Unpivot or pivot SQL

    I have some tables, only one row, but many columns, like this:
    Name Null? Type
    column1 NUMBER
    column2 VARCHAR2(9)
    column3 VARCHAR2(9)
    column99 VARCHAR2(9)
    I want a SQL to generate this kind of result:
    Column1 : 1
    Column2 : Oracle
    Column3 : DB2
    Column99 : SQL Server
    This SQL could run in 8i,9i,10g and 11g.
    Thanks,

    In asktom you can search for a function called PRINT_TABLE. I have modified a little to use it as a table function.
    drop type table_object
    drop type column_object
    drop function print_table
    create type column_object as object(column_name varchar2(30), column_values varchar2(4000))
    create type table_object as table of column_object
    create or replace function print_table( p_query in varchar2 ) return table_object pipelined
    is
        l_theCursor     integer default dbms_sql.open_cursor;
        l_columnValue   varchar2(4000);
        l_status        integer;
        l_descTbl       dbms_sql.desc_tab;
        l_colCnt        number;
    begin
        execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss'' ';
        dbms_sql.parse(  l_theCursor,  p_query, dbms_sql.native );
        dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
        for i in 1 .. l_colCnt loop
            dbms_sql.define_column(l_theCursor, i, l_columnValue, 4000);
        end loop;
        l_status := dbms_sql.execute(l_theCursor);
        while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
            for i in 1 .. l_colCnt loop
                dbms_sql.column_value ( l_theCursor, i, l_columnValue );
                pipe row (column_object(l_descTbl(i).col_name,l_columnValue));
            end loop;
        end loop;
        execute immediate 'alter session set nls_date_format=''dd-MON-rr'' ';
        return;
    exception
        when others then
          execute immediate 'alter session set nls_date_format=''dd-MON-rr'' ';
          raise;
    end;
    show errSo this would work like this.
    SQL> select * from table(print_table('select * from emp'))
      2  /
    COLUMN_NAME                    COLUMN_VALUES
    EMPNO                          1
    DEPTNO                         1
    ENAME                          Karthick
    SAL                            80
    DOJ                            03-dec-2011 04:31:17
    JOB
    MGR
    EMPNO                          2
    DEPTNO                         1
    ENAME                          Karthick_1
    SAL                            90
    DOJ                            23-nov-2011 04:31:17
    JOB
    MGR                            1
    EMPNO                          3
    DEPTNO                         2
    ENAME                          1
    SAL                            80
    DOJ                            03-dec-2011 04:31:17
    JOB
    MGR
    EMPNO                          4
    DEPTNO                         2
    ENAME                          Ram_1
    SAL                            90
    DOJ                            23-nov-2011 04:31:17
    JOB
    MGR                            3
    28 rows selected.
    SQL>
    This SQL could run in 8i,9i,10g and 11g.Oh boy i cant say that :)

  • Help, Pivot SQL

    I am doing a report for a book store. We have data like:
    STORE_ID SUBJECT     SUB_DETAIL     NUMBERS
    1001     CD     CD_TITLE1     2
    1001     CD     CD_TITLE2     4
    1001     CD     CD_TITLE3     1
    1001     DVD     DVD_TITLE1     7
    1001     DVD     DVD_TITLE2     5
    1001     DVD     DVD_TITLE3     3
    1001     DVD     DVD_TITLE4     2
    1001     BOOK     BOOK_TITLE1     6
    1001     BOOK     BOOK_TITLE2     2
    1001     OTHERS     OTHERS1     9
    1001     OTHERS     OTHERS2     1
    1001     OTHERS     OTHERS3     8
    1001     OTHERS     OTHERS4     2
    1001     OTHERS     OTHERS5     3
    We want to display the data like:
    STORE_ID CD CD_NUM DVD DVD_NUM BOOK BOOK_NUM OTHERS     OTHERS_NUM
    It can not show the format I want.
    Thanks a lot for any help!
    Jeanne

    nikos101 wrote:
    > How would change this query to display a table like:
    Do you *HAVE* to change the query... you could just display
    it in the
    desired format if that it the ultimate and only goal.
    <table>
    <tr>
    <td>name</td>
    <td>amount</td>
    </tr>
    <cfoutput query="sumQry">
    <tr><td>Rates</td><td>#rates#</td></tr>
    <tr><td>Conversion</td><td>#conversion#</td></tr>
    </cfoutput>
    </table>

  • Sql query with multiple joins to same table

    I have to write a query for a client to display business officers' names and title along with the business name
    The table looks like this
    AcctNumber
    OfficerTitle
    OfficerName
    RecKey
    90% of the businesses have exactly 4 officer records, although some have less and some have more.
    There is a separate table that has the AcctNumber, BusinessName about 30 other fields that I don’t need
    An individual account can have 30 or 40 records on the other table.
    The client wants to display 1 record per account.
    Initially I wrote a query to join the table to itself:
    Select A.OfficerTtitle, A.OfficerName, B.OfficerTitle, B.OfficerName, C.OfficerTtitle, C.OfficerName, D.OfficerTitle, D.OfficerName where A.AcctNumber = B.AcctNumber and A.AcctNumber = C.AcctNumber and A.AcctNumber = D.AcctNumber
    This returned tons of duplicate rows for each account ( number of records * number of records, I think)
    So added
    And A.RecKey > B.RecKey and B.RecKey > C. RecKey and C.RecKey . D.RecKey
    This works when there are exactly 4 records per account. If there are less than 4 records on the account it skips the account and if there are more than 4 records, it returns multiple rows.
    But when I try to l join this to the other table to get the business name, I get a row for every record on the other table
    I tried select distinct on the other table and the query runs for ever and never returns anything
    I tried outer joins and subqueries, but no luck so far. I was thinking maybe a subquery - if exists - because I don't know how many records there are on an account, but don't know how to structure that
    Any suggestions would be appreciated

    Welcome to the forum!
    user13319842 wrote:
    I have to write a query for a client to display business officers' names and title along with the business name
    The table looks like this
    AcctNumber
    OfficerTitle
    OfficerName
    RecKey
    90% of the businesses have exactly 4 officer records, although some have less and some have more.
    There is a separate table that has the AcctNumber, BusinessName about 30 other fields that I don’t need
    An individual account can have 30 or 40 records on the other table.
    The client wants to display 1 record per account.As someone has already mentioned, you should post CREATE TABLE and INSERT statements for both tables (relevant columns only). You don't have to post a lot of sample data. For example, you need to pick 1 out of 30 or 40 rows (max) for the same account, but it's almost certainly enough if you post only 3 or 4 rows (max) for an account.
    Also, post the results you want from the sample data that you post, and explain how you get those resutls from that data.
    Always say which version of Oracle you're using. This sounds like a PIVOT problem, and a new SELECT .... PIVOT feature was introduced in Oracle 11.1. If you're using Oracle 11, you don't want to have to learn the old way to do pivots. On the other hand, if you have Oracle 10, a solution that uses a new feature that you don't have won't help you.
    Whenever you have a question, please post CREATE TABLE and INSERT statements for some sample data, the results you want from that data, an explanation, and your Oracle version.
    Initially I wrote a query to join the table to itself:
    Select A.OfficerTtitle, A.OfficerName, B.OfficerTitle, B.OfficerName, C.OfficerTtitle, C.OfficerName, D.OfficerTitle, D.OfficerName where A.AcctNumber = B.AcctNumber and A.AcctNumber = C.AcctNumber and A.AcctNumber = D.AcctNumber Be careful, and post the exact code that you're running. The statement above can't be what you ran, because it doesn't have a FROM clause.
    This returned tons of duplicate rows for each account ( number of records * number of records, I think)
    So added
    And A.RecKey > B.RecKey and B.RecKey > C. RecKey and C.RecKey . D.RecKey
    This works when there are exactly 4 records per account. If there are less than 4 records on the account it skips the account and if there are more than 4 records, it returns multiple rows.
    But when I try to l join this to the other table to get the business name, I get a row for every record on the other table
    I tried select distinct on the other table and the query runs for ever and never returns anything
    I tried outer joins and subqueries, but no luck so far. I was thinking maybe a subquery - if exists - because I don't know how many records there are on an account, but don't know how to structure that
    Any suggestions would be appreciatedDisplaying 1 column from n rows as n columns on 1 row is called Pivoting . See the following link fro several ways to do pivots:
    SQL and PL/SQL FAQ
    Pivoting requires that you know exactly how many columns will be in the result set. If that number depends on the data in the table, then you might prefer to use String Aggregation , where the output consists of a huge string column, that contains the concatenation of the data from n rows. This big string can be formatted so that it looks like multiple columns. For different string aggregation techniques, see:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    The following thread discusses some options for pivoting a variable number of columns:
    Re: Report count and sum from many rows into many columns

  • Pivote a string

    Hi Forum ,
    I have a table test12 like below (name and value are 2 columns of the table)
    name value
    app1     aw
    app1     br
    app1     sdf
    app1     dx
    app1     esd
    app2     aw
    app2     dx
    app2     esd
    scripts :
    create table test12 ( name varchar2(100),value varchar2(100));
    insert into test12 values('app1','aw');
    insert into test12 values('app1','br');
    insert into test12 values('app1','sdf');
    insert into test12 values('app1','dx');
    insert into test12 values('app1','esd');
    insert into test12 values('app1','aw');
    insert into test12 values('app2','dx');
    insert into test12 values('app2','esd');
    commit;
    select * from test12;
    and I have to write a query to see above data as below
    col1 col2 col3 col4 col5 col6
    app1 aw br sdf dx esd
    app2 aw dx esd
    --here the values will grow dynamically and our query should able to add new column like col7,col8 ..
    Please let me know for more info .
    select * from v$version;
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Thanks ,
    Mahesh

    A basic attempt at implementing Frank's dynamic pivot method as an object class in Oracle:
    SQL> create or replace type TStringArray is table of varchar2(4000);
      2  /
    Type created.
    SQL>
    SQL> create or replace type TDynamicPivot is object(
      2          table_name              varchar2(30),
      3          standard_columns        varchar2(4000),
      4          pivot_column            varchar2(30),
      5          order_by                varchar2(4000),
      6          column_name             TStringArray,
      7          column_values           TStringArray,
      8 
      9          member function GetSQL return varchar2,
    10          member function GetRefCursor return sys_refcursor
    11  );
    12  /
    Type created.
    SQL>
    SQL> create or replace type body TDynamicPivot as
      2 
      3          member function GetSQL return varchar2 is
      4                  sqlSelect       varchar2(32767);
      5          begin
      6                  sqlSelect := 'select '||chr(10)||chr(9)||self.standard_columns;
      7 
      8                  for i in 1..self.column_name.Count loop
      9                          sqlSelect := sqlSelect||chr(10)||chr(9)||','||
    10                                  'sum( case when '||self.pivot_column||'='''||
    11                                  self.column_values(i)||''' then 1 else 0 end ) as "'||
    12                                  self.column_name(i)||'"';
    13                  end loop;
    14 
    15                  sqlSelect := sqlSelect || chr(10)||'from '||self.table_name||chr(10)||
    16                          'group by '||self.standard_columns||chr(10)||
    17                          'order by '||self.order_by;
    18 
    19                  return( sqlSelect );
    20          end;
    21 
    22          member function GetRefCursor return sys_refcursor is
    23                  c sys_refcursor;
    24          begin
    25                  open c for self.GetSQL();
    26                  return( c );
    27          end;
    28  end;
    29  /
    Type body created.
    SQL> var c refcursor
    SQL>
    SQL> declare
      2          pivot   TDynamicPivot;
      3  begin
      4          pivot := new TDynamicPivot(
      5                          'emp', 'deptno', 'job',
      6                          '1',
      7                          TStringArray('ANALYST','CLERK','MANAGER','PRESIDENT','SALESMAN'),
      8                          TStringArray('ANALYST','CLERK','MANAGER','PRESIDENT','SALESMAN')
      9                  );
    10          DBMS_OUTPUT.put_line( 'Pivot SQL:' );
    11          DBMS_OUTPUT.put_line( pivot.GetSQL() );
    12 
    13          :c := pivot.GetRefCursor();
    14  end;
    15  /
    Pivot SQL:
    select
            deptno
            ,sum( case when job='ANALYST' then 1 else 0 end ) as "ANALYST"
            ,sum( case when job='CLERK' then 1 else 0 end ) as "CLERK"
            ,sum( case when job='MANAGER' then 1 else 0 end ) as "MANAGER"
            ,sum( case when job='PRESIDENT' then 1 else 0 end ) as "PRESIDENT"
            ,sum( case when job='SALESMAN' then 1 else 0 end ) as "SALESMAN"
    from emp
    group by deptno
    order by 1
    PL/SQL procedure successfully completed.
    SQL>
    SQL> print c
        DEPTNO    ANALYST      CLERK    MANAGER  PRESIDENT   SALESMAN
            10          0          1          1          1          0
            20          2          2          1          0          0
            30          0          1          1          0          4
    SQL>
    SQL>
    SQL> with pivot as(
      2          select
      3                  TDynamicPivot(
      4                          'all_objects', 'owner', 'object_type',
      5                          '1',
      6                          TStringArray('TABLES','INDEXES','PROCEDURES'),
      7                          TStringArray('TABLE','INDEX','PROCEDURE')
      8                  )       as OBJECT
      9          from    dual
    10  )
    11  select
    12          p.object.GetRefCursor() as "REFCURSOR",
    13          p.object.GetSQL()       as "SQL"
    14  from       pivot p;
    REFCURSOR            SQL
    CURSOR STATEMENT : 1 select
                            owner
                            ,sum( case when object_type='TABLE' then 1 else 0 end ) as "TABLES"
                            ,sum( case when object_type='INDEX' then 1 else 0 end ) as "INDEXES"
                            ,sum( case when object_type='PROCEDURE' then 1 else 0 end ) as "PROCEDURES"
                         from all_objects
                         group by owner
                         order by 1
    CURSOR STATEMENT : 1
    OWNER                              TABLES    INDEXES PROCEDURES
    APEX_040100                             1          0         13
    BILLY                                   4          2          3
    CTXSYS                                  5          0          0
    DBSNMP                                  0          0          0
    EXFSYS                                  1          0          1
    MDM                                    74          0          0
    MDSYS                                  34          0          0
    OLAPSYS                                 2          0          0
    ORDDATA                                 0          0          0
    ORDPLUGINS                              0          0          0
    ORDSYS                                  0          0          7
    PUBLIC                                  0          0          0
    SYS                                    33          0         17
    SYSTEM                                  7          0          0
    TYPE                                    0          0          1
    WMSYS                                   0          0          0
    XDB                                    17          0          0
    SQL>
    SQL> with pivot as(
      2          select
      3                  TDynamicPivot(
      4                  'all_objects', 'owner', 'object_type',
      5                  '1',
      6                  cast( multiset(select distinct object_type from user_objects order by 1) as TStringArray ),
      7                  cast( multiset(select distinct object_type from user_objects order by 1) as TStringArray )
      8          )       as OBJECT
      9  from       dual
    10  )
    11  select
    12          p.object.GetRefCursor() as "REFCURSOR",
    13          p.object.GetSQL()       as "SQL"
    14  from       pivot p;
    REFCURSOR            SQL
    CURSOR STATEMENT : 1 select
                            owner
                            ,sum( case when object_type='DATABASE LINK' then 1 else 0 end ) as "DATABASE LINK"
                            ,sum( case when object_type='FUNCTION' then 1 else 0 end ) as "FUNCTION"
                            ,sum( case when object_type='INDEX' then 1 else 0 end ) as "INDEX"
                            ,sum( case when object_type='PACKAGE' then 1 else 0 end ) as "PACKAGE"
                            ,sum( case when object_type='PACKAGE BODY' then 1 else 0 end ) as "PACKAGE BODY"
                            ,sum( case when object_type='PROCEDURE' then 1 else 0 end ) as "PROCEDURE"
                            ,sum( case when object_type='TABLE' then 1 else 0 end ) as "TABLE"
                            ,sum( case when object_type='TYPE' then 1 else 0 end ) as "TYPE"
                            ,sum( case when object_type='TYPE BODY' then 1 else 0 end ) as "TYPE BODY"
                         from all_objects
                         group by owner
                         order by 1
    CURSOR STATEMENT : 1
    OWNER                          DATABASE LINK   FUNCTION      INDEX    PACKAGE PACKAGE BODY  PROCEDURE      TABLE       TYPE  TYPE BODY
    APEX_040100                                0          4          0         56            0         13          1          2          0
    BILLY                                      0          1          2          1            1          3          4          8          4
    CTXSYS                                     0          0          0         13            0          0          5          9          0
    DBSNMP                                     0          0          0          1            0          0          0          0          0
    EXFSYS                                     0          4          0          7            0          1          1         27          0
    MDM                                        0          0          0          0            0          0         74          0          0
    MDSYS                                      0         72          0         19            0          0         34        145          0
    OLAPSYS                                    0          0          0          3            0          0          2          0          0
    ORDDATA                                    0          0          0          0            0          0          0          0          0
    ORDPLUGINS                                 0          0          0          5            0          0          0          0          0
    ORDSYS                                     0         32          0         19            0          7          0        446          0
    PUBLIC                                     0          0          0          0            0          0          0          0          0
    SYS                                        0         86          0        226            0         17         33        762          0
    SYSTEM                                     0          0          0          0            0          0          7          0          0
    TYPE                                       0          0          0          0            0          1          0         14          0
    WMSYS                                      0          4          0          6            0          0          0          8          0
    XDB                                        0          5          0         28            0          0         17         90          0
    SQL>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SELECT ... PIVOT .. ORA-00936

    Oracle database: 11.2.0.2.0
    I'm trying to pivot a query that returns parameter names/values for a given key into a row that lists the key and then a column for each pair where the parameter name becomes the column name. The 11g SQL reference indicates that the pivot_in_clause can take a subquery. So I was trying to use the subquery to avoid hard-coding the column names, to no avail.
    Given...
    KEY PNAME PVALUE
    10 P1 V1
    10 P2 V2
    10 P3 V3
    I would like the query to return...
    KEY P1 P2 P3
    10 V1 V2 V3
    I can do this with the following query...
    WITH pivot_data AS ( SELECT * FROM pnosko_pivot WHERE key = 10 ORDER BY pname )
    SELECT *
    FROM pivot_data
    PIVOT ( MAX(pvalue)
    FOR pname
    IN ('P1' as p1,'P2' as p2,'P3' as p3) );
    But if I try and use a subquery as follows (to allow for new parameter rows to be handled dynamically), I get an ORA-00936.
    WITH pivot_data AS ( SELECT * FROM pnosko_pivot WHERE key = 10 ORDER BY pname )
    SELECT *
    FROM pivot_data
    PIVOT ( MAX(pvalue)
    FOR pname
    IN (SELECT DISTINCT pname FROM pnosko_pivot WHERE key = 10 ORDER BY 1) );
    Could someone point to my problem, interpretation or otherwise? Thanks.

    PIVOT is static. You must list every column explicitly. You can't use subquery for that. The only suppoted dynamic PIVOT is XML pivot:
    SQL> set long 10000
    SQL> select  *
      2    from  (
      3           select  job,
      4                   deptno,
      5                   sal
      6             from  emp
      7          ) pivot xml(sum(sal) for job in (select distinct job from emp))
      8  /
        DEPTNO
    JOB_XML
            10
    <PivotSet><item><column name = "JOB">ANALYST</column><column name = "SUM(SAL)"><
    /column></item><item><column name = "JOB">CLERK</column><column name = "SUM(SAL)
    ">1300</column></item><item><column name = "JOB">MANAGER</column><column name =
    "SUM(SAL)">2450</column></item><item><column name = "JOB">PRESIDENT</column><col
    umn name = "SUM(SAL)">5000</column></item><item><column name = "JOB">SALESMAN</c
    olumn><column name = "SUM(SAL)"></column></item></PivotSet>
            20
        DEPTNO
    JOB_XML
    <PivotSet><item><column name = "JOB">ANALYST</column><column name = "SUM(SAL)">6
    000</column></item><item><column name = "JOB">CLERK</column><column name = "SUM(
    SAL)">1900</column></item><item><column name = "JOB">MANAGER</column><column nam
    e = "SUM(SAL)">2975</column></item><item><column name = "JOB">PRESIDENT</column>
    <column name = "SUM(SAL)"></column></item><item><column name = "JOB">SALESMAN</c
    olumn><column name = "SUM(SAL)"></column></item></PivotSet>
            30
    <PivotSet><item><column name = "JOB">ANALYST</column><column name = "SUM(SAL)"><
        DEPTNO
    JOB_XML
    /column></item><item><column name = "JOB">CLERK</column><column name = "SUM(SAL)
    ">950</column></item><item><column name = "JOB">MANAGER</column><column name = "
    SUM(SAL)">2850</column></item><item><column name = "JOB">PRESIDENT</column><colu
    mn name = "SUM(SAL)"></column></item><item><column name = "JOB">SALESMAN</column
    <column name = "SUM(SAL)">5600</column></item></PivotSet>
    SQL> But it doesn't give you much...
    SY.

  • Excel Trying to Load PowerPivot Add-in (version 11.1.3129.0) for Excel 2010 even after Uninstalltion of the Add-in.

    Hi all,
    I am trying to Package and deploy Powerpivot Add-in for Excel 2010. I have the Powerpivot_X86_(11.1.329.0) .MSI which installs Unattended, but Uninstallation will not remove entry from COM ADD-IN list in Excel and at first re-launch (even after
    Power Pivot Uninstallation) it will try to load Powerpivot add-in and will give an error.
    Downloading file.///c:/Program files (x86)/Microsoft analysis services/AS Excel Client/110/Microsoft.AnalysisServices.XLHost.Addin.VSTO did not succeed.
    this above path is the [InstallDir] which gets wiped off with the unistallation of the .MSI. So, before uninstallation,I stop the excel process and am running a script to delete HKCU Add-in Reg key entries.
    and also, I thought it may be implicitly loading the add-in from folder such as,
    C:\Program Files\Microsoft Office\Office14\XLstart
    %appdata%\Microsoft\Excel\XLSTART
    but nothing is installed there.
    Second Issue
    when I re-install,
    it doesn't automatically show up in the Excel ribbon (even after reboot and even if regeistries are created at the same location) but instead we should add it through COM ADD-IN list in Excel Manually.
    Appreciate any idea's and suggestion's.
    P.S
    is it possible to make it completely installed per system rather having user entries?
    Error Details:
    Name:
    From: file:///C:/Program Files (x86)/Microsoft Analysis Services/AS Excel Client/110/Microsoft.AnalysisServices.XLHost.Addin.vsto
    ************** Exception Text **************
    System.Deployment.Application.DeploymentDownloadException: Downloading file:///C:/Program Files (x86)/Microsoft Analysis Services/AS Excel Client/110/Microsoft.AnalysisServices.XLHost.Addin.vsto did
    not succeed. ---> System.Net.WebException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Analysis Services\AS Excel Client\110\Microsoft.AnalysisServices.XLHost.Addin.vsto'. ---> System.Net.WebException: Could not find a part of
    the path 'C:\Program Files (x86)\Microsoft Analysis Services\AS Excel Client\110\Microsoft.AnalysisServices.XLHost.Addin.vsto'. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Analysis Services\AS
    Excel Client\110\Microsoft.AnalysisServices.XLHost.Addin.vsto'.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES
    secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async)
       at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
       --- End of inner exception stack trace ---
       at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
       at System.Net.FileWebRequest.GetResponseCallback(Object state)
       --- End of inner exception stack trace ---
       at System.Net.FileWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.Net.FileWebRequest.GetResponse()
       at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
       --- End of inner exception stack trace ---
       at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
       at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()

    Guys, I think I solved the
    issue:
    Symptoms
    1. Power Pivot SQL 2012 32-bit installed over the old version without
    deinstalling it
    2. Installed with a user with administrator rights
    3. It worked under the profile with admin rights, it didn't work under the
    normal users w/o admin rights and threw this error message: Downloading file.///c:/Program files (x86)/Microsoft analysis services/AS Excel Client/10/Microsoft.AnalysisServices.XLHost.Addin.VSTO
    did not succeed.
    4. In the admin profile, it went to the path "110":  C:/Program
    Files (x86)/Microsoft Analysis Services/AS Excel
    Client/110/Microsoft.AnalysisServices.Modeler.FieldList.vsto
    5. In the normal profile, it went to the - wrong - "10" path:
    C:/Program Files (x86)/Microsoft Analysis Services/AS Excel
    Client/10/Microsoft.AnalysisServices.Modeler.FieldList.vsto
    SOLUTION
    1. ADMIN: Installed VSTO 4.0
    2. ADMIN: Checked if the .NET Programmability Support was installed - it was -
    if not, install it!
    3. NORMAL USER: Create a .reg file (Backup your registry before!) and
    use it UNDER THE NORMAL USER!!!
    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Office\Excel][HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins][HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\Microsoft.AnalysisServices.Modeler.FieldList]
    "Description"="Microsoft SQL Server PowerPivot for Microsoft Excel"
    "FriendlyName"="PowerPivot for Excel"
    "LoadBehavior"=dword:00000003
    "Manifest"="C:\\Program Files\\Microsoft Analysis Services\\AS
    Excel Client\\110\\Microsoft.AnalysisServices.XLHost.Addin.vsto|vstolocal"
    "CartridgePath"="C:\\Program Files\\Microsoft Analysis
    Services\\AS OLEDB\\110\\Cartridges\\"
    4. NORMAL USER: Rename the registry key
    "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\User Settings\Microsoft.AnalysisServices.Modeler.FieldList"
    into
    "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\User
    Settings\Microsoft.AnalysisServices.Modeler.FieldList_old"
    5. NORMAL USER: Start up Power Pivot and it should
    work now!
    Analysis
    IMHO the issue lies in the fact, that the Power Pivot
    installer creates two problems:
    The first issue is that the path to the add-in under
    the NORMAL user is simply wrong and points to a wrong location (the
    "10" in the path). In the admin profile, where it was originally
    installed, it points to the "110" path which is correct.
    The second issue is that the installation procedure
    somehow needs to create a registry key (the one under point 4 in the solution)
    to complete it self and if this key already exists it fails to install and
    throws up weird error messages. If you delete or rename this key, it is created
    again (exactly in the same way) but then everything works out.
    Hope this
    helps!
    Regards, Reto

  • Unpivot multiple products fields data dynamically

    Hi,
    I am having data as below;
       ID
          CMC
          EMS   
            KBP
    Week1
    501378
    320967
    822.54
    Week2
    13500
    6000
    3000
    Week3
    34534
    63563
    9868
    Week4
    32523
    32532
    54223
    Week5
    235235
    53453
    34534
    Week6
    34534
    534534
    34534
    I want to show the above data like below;
    Product
        Week1
         Week2
        Week3
        Week4
        Week5
        Week6
    CMC
    501378
    13500
    34534
    32523
    235235
    34534
    EMS
    320967
    6000
    63563
    32532
    53453
    534534
    KBP
    822.54
    3000
    9868
    54223
    34534
    34534
    I tried the following query: 
    declare @ListWeekData varchar(max)
    declare @query nvarchar(max)
    SET @ListWeekData = STUFF((SELECT distinct ',' + QUOTENAME(convert(varchar,WeekOfMonth))   
                FROM  #WeeklyBreakupData
                FOR XML PATH(''), TYPE  
                ).value('.', 'NVARCHAR(MAX)')   
            ,1,1,'') 
    print @ListWeekData
    SELECT @query = 'SELECT Product
      FROM 
      #WeeklyBreakupData
      UNPIVOT
        Producta FOR Product IN (' + STUFF(@ListWeekData, 1, 1, '') + ')
      ) AS up;';
    PRINT @query;
     EXEC (@query);
    drop table #WeeklyBreakupData
    but unable to get the desired result. Please help me out ASAP.
    Thanks,
    Srini

    Here you go
    CREATE TABLE tmp (Name CHAR(1),Forecast INT,Stock INT)
    INSERT tmp SELECT 'a',100,300  
    INSERT tmp SELECT 'b',300,400 
    INSERT tmp SELECT 'c',200,250
    INSERT tmp SELECT 'd',200,300
    -- dynamic pivot (SQL Server 2005/2008)
    DECLARE @pivot_cols NVARCHAR(1000);
    SELECT @pivot_cols =
            STUFF((SELECT DISTINCT '],[' + Name
                   FROM tmp
                   ORDER BY '],[' + Name
                   FOR XML PATH('')
                   ), 1, 2, '') + ']';
    DECLARE @pivot_query NVARCHAR(2000);
    SET @pivot_query =
    N'SELECT * FROM (
    SELECT * FROM (
    SELECT Name,SUM(Forecast) Forecast,SUM(Stock) Stock FROM tmp
    GROUP BY Name ) tmp UNPIVOT
     Col for [GROUP] IN (Forecast,Stock)
    ) as UnPvt ) pvt
    PIVOT (MAX(Col) FOR Name IN (' + @pivot_cols + ')) j'
    EXEC(@pivot_query);
    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

  • Powerpivot add-in installation issue "Could not find a part of the path"

    Hello, 
    I got a Windows Server 2008R2 terminal server with Office 2010 and Powerpivot installed. I have an issue for some users, not every user get this error. When trying to add the Powerpivot add-in in Excel the following error message is displayed: 
    Name: 
    From: file:///C:/Program Files (x86)/Microsoft Analysis Services/AS Excel Client/10/Microsoft.AnalysisServices.Modeler.FieldList.vsto
    ************** Exception Text **************
    System.Deployment.Application.DeploymentDownloadException: Downloading file:///C:/Program Files (x86)/Microsoft Analysis Services/AS Excel Client/10/Microsoft.AnalysisServices.Modeler.FieldList.vsto did not succeed. ---> System.Net.WebException:
    Could not find a part of the path 'C:\Program Files (x86)\Microsoft Analysis Services\AS Excel Client\10\Microsoft.AnalysisServices.Modeler.FieldList.vsto'. ---> System.Net.WebException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft
    Analysis Services\AS Excel Client\10\Microsoft.AnalysisServices.Modeler.FieldList.vsto'. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Analysis Services\AS Excel Client\10\Microsoft.AnalysisServices.Modeler.FieldList.vsto'.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing, Int32 length, Boolean async)
       at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
       --- End of inner exception stack trace ---
       at System.Net.FileWebResponse..ctor(FileWebRequest request, Uri uri, FileAccess access, Boolean asyncHint)
       at System.Net.FileWebRequest.GetResponseCallback(Object state)
       --- End of inner exception stack trace ---
       at System.Net.FileWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.Net.FileWebRequest.GetResponse()
       at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
       --- End of inner exception stack trace ---
       at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
       at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
    I have checked the path and I found nothing. I could understand the problem if all users got this error but it's online a handfew of users. Other users can add the add-in in Excel without any issue. All the users are in the same domain and they use the one
    and only terminal server on the site.
    Any advice? I've searched the web but haven't found anything.
    Thanks in advance!

    Guys, I think I solved the
    issue:
    Symptoms
    1. Power Pivot SQL 2012 32-bit installed over the old version without
    deinstalling it
    2. Installed with a user with administrator rights
    3. It worked under the profile with admin rights, it didn't work under the
    normal users w/o admin rights and threw this error message: Downloading file.///c:/Program files (x86)/Microsoft analysis services/AS Excel Client/10/Microsoft.AnalysisServices.XLHost.Addin.VSTO
    did not succeed.
    4. In the admin profile, it went to the path "110":  C:/Program
    Files (x86)/Microsoft Analysis Services/AS Excel
    Client/110/Microsoft.AnalysisServices.Modeler.FieldList.vsto
    5. In the normal profile, it went to the - wrong - "10" path:
    C:/Program Files (x86)/Microsoft Analysis Services/AS Excel
    Client/10/Microsoft.AnalysisServices.Modeler.FieldList.vsto
    SOLUTION
    1. ADMIN: Installed VSTO 4.0
    2. ADMIN: Checked if the .NET Programmability Support was installed - it was -
    if not, install it!
    3. NORMAL USER: Create a .reg file (Backup your registry before!) and
    use it UNDER THE NORMAL USER!!!
    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Office\Excel][HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins][HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\Microsoft.AnalysisServices.Modeler.FieldList]
    "Description"="Microsoft SQL Server PowerPivot for Microsoft Excel"
    "FriendlyName"="PowerPivot for Excel"
    "LoadBehavior"=dword:00000003
    "Manifest"="C:\\Program Files\\Microsoft Analysis Services\\AS
    Excel Client\\110\\Microsoft.AnalysisServices.XLHost.Addin.vsto|vstolocal"
    "CartridgePath"="C:\\Program Files\\Microsoft Analysis
    Services\\AS OLEDB\\110\\Cartridges\\"
    4. NORMAL USER: Rename the registry key
    "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\User Settings\Microsoft.AnalysisServices.Modeler.FieldList"
    into
    "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\User
    Settings\Microsoft.AnalysisServices.Modeler.FieldList_old"
    5. NORMAL USER: Start up Power Pivot and it should
    work now!
    Analysis
    IMHO the issue lies in the fact, that the Power Pivot
    installer creates two problems:
    The first issue is that the path to the add-in under
    the NORMAL user is simply wrong and points to a wrong location (the
    "10" in the path). In the admin profile, where it was originally
    installed, it points to the "110" path which is correct.
    The second issue is that the installation procedure
    somehow needs to create a registry key (the one under point 4 in the solution)
    to complete it self and if this key already exists it fails to install and
    throws up weird error messages. If you delete or rename this key, it is created
    again (exactly in the same way) but then everything works out.
    Hope this
    helps!
    Regards, Reto

  • Transpose Data in CLR Stored procedure

    We have huge data table(600 columns and 800 rows approx) which we want to transpose 600 rows and 800 columns in a CLR stored procedure.
    Currently am using a datatable to the transpose. Could anyone suggest any better options other than datatable which gives better performance?

    Hi Hari,
    If my understand is correct, please consider using unpivot or pivot sql:
    http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
    http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/
    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Matrix Style Reports

    Hi,
    I'd be interested in ideas for producing a matrix-style report (similar to that possible with Oracle Discoverer or Pivot Tables in spreadsheets). Example below. I've tried dynamic SQL (report based on function returning a SQL query) but this quickly gets very complex.
    Are API's available (similar to the form item api's) for laying out HTMLDB sytle report headings and rows directly ?
    Matrix Example
    Imagine you have sales data by product and date e.g.
    Product Date Sales
    A 2003 100
    A 2004 75
    B 2003 50
    I would like to display a matrix report similar to
    Sales 2003 2004 ...
    A 100 75
    B 50 ...
    ...

    htmldb currently installs with a package called wwv_flow_rewrite_query. it's not technically supported, but it's really solid code ...and i think it does pretty much what you're hoping to do (pivot sql query). if you look in your $OHS_HOME/marvel directory you should see a file there called wwv_flow_rewrite_query.sql. fortunately that package isn't wrapped. better yet, it's loaded down with documentation. i'd take a look there to see about your report. if you have questions on the concepts (not the package), the author can be found discussing the topic at...
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:766825833740,
    ...but basically, you'd us the package to rewrite your query, returning wwv_flow_rewrite_query.as_pivot to the htmldb reporting engine in your Function Returning SQL Query region.
    ...hope this helps,
    raj

Maybe you are looking for