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}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Pivoting and string manipulation

    Hi Guys I would appreciate your help with this.
    I have a table with a single column= A1, A2, B1, C1, C2 which I need to pivot and write the following rows to a second table again as a single column;
    A1,B1,C1
    A1,B1,C2
    A2,B1,C1
    A2,B1,C2
    An example would be great. Thanks in advance.
    Gaz

    Hi,
    Gaz wrote:
    ... Hope this covers all your questionsNo.
    Frank Kulash wrote:
    ... Explain the business rules as clearly as you can. Why don't you want rows like the following in the second table:
    C1, B1, A1
    B1, B1, B1
    A1, A2, B1or do you?
    Do you know, in advance, that the strings all start with 'A', 'B' or 'C', or does the query have to figure out what the different possibilites are?I made several guesses.
    INSERT INTO     target_tab (col1)
    WITH  normalized_source_tab     AS
         SELECT     REGEXP_SUBSTR ( col1
                                , '[^ ,]+'
                         , 1
                         , LEVEL
                         )          AS txt
         ,     DENSE_RANK () OVER ( ORDER BY  REGEXP_SUBSTR ( col1
                                                                     , '[^ ,0-9]+'
                                                  , 1
                                                  , LEVEL
                                 )          AS prefix_num
         FROM     source_tab
         CONNECT BY     LEVEL <= 1 + LENGTH (col1)
                                 - LENGTH (REPLACE (col1, ','))
    SELECT     SUBSTR ( SYS_CONNECT_BY_PATH (txt, ', ')
                , 3
    FROM     normalized_source_tab
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     prefix_num     = 1
    CONNECT BY     prefix_num     = 1 + PRIOR prefix_num     
    ;Among other things, I guessed that the comma-delimited items in sorce_tab.col1 always follow this pattern:
    (1) Optional spaces, to be ignored
    (2) Non-digits, which deterrmine the postion in target_tab.col1
    (3) Digits
    Either (2) or (3), but not both, may be omitted. If both are present, (3) may come before (2).

  • Wrapping my head around PIVOT - Arggggg

    Ok, I am stumped. What I want seems so simple to me....
    ======= Table Def
    CREATE TABLE "TI" (
    "SNUM" NUMBER,
    "SYMBOL" VARCHAR2(30),
    "OPEN" NUMBER(15, 5),
    "LOW" NUMBER(15, 5),
    "HIGH" NUMBER(15, 5),
    "CLOSE" NUMBER(15, 5),
    "ADJ_CLOSE" NUMBER(15, 5),
    "VOLUME" NUMBER(15, 5),
    "CHANGE_PCT" NUMBER(15, 5),
    "CHANGE_AMT" NUMBER(15, 5),
    "TIMESTAMP" TIMESTAMP(9) DEFAULT systimestamp ,
    "TRADE_DATE" DATE,
    "DATA_SOURCE" NUMBER)
    ============ data
    insert into TI (6975 ,'VT', 48.2,48.11, 48.41,48.23,48.23,200500,.009,.43,'01-JAN-11','08.32.57.366984000 PM','03-JAN-11',2)
    insert into TI (6995,' AGG',105.4,105.3,105.68,105.63,105.63,739700,-.00113,-.12,'31-JAN-11 08.33.18.137327000 PM','03-JAN-11',2)
    insert into TI(7015,'SPY',126.71,125.7,127.6,127.05,127.05,138725200,.01034,1.3,'31-JAN-11 08.33.34.708030000 PM','03-JAN-11',2)
    So as you can see these are all on the same date. We currently collect three indices every day, but a user with the click of a mouse could add another or take one away.
    What I am trying to do is get output gives a date and the indices contained in a given day and their adj_close as a single return value from a query.
    I have spent the day trying to wrap my head around PIVOT or LISTAGG but just can't seem to get a grasp of the damn thing. All the examples I have seen incluse sums and such and I need, nor in fact do I want anything summed. This would seem to come down to grouping by the trade_date and that where something is just not making sense.
    More then an answer ( although an answer would be very helpful :) ) It would be great if someone could simply lay out how this is supposed to work. Uhm did I say an answer would be helpful <big cheesy smile >
    Thanks in advance...

    Hi,
    Thanks for posting the CREATE TABLE and INSERT statements. Please test any code before you post it; there seem to be a lot of mistakes in those 4 statements. Don't forget to post the results you want from the sample data, and your version of Oracle.
    One thing that is common to all forms of pivoting or string aggregation is that you need to know, for each row of input, to which row and which column(s) (or position(s)) of output it corresponds. Sometimes one or both of these are already in the data, but sometimes they have to be derived from the data. I'll assume you have one of each: that trade_date indicates the output row, and that the column you called timestamp (but which I'll call tmstmp, since timestamp isn't a good column name) can be used to tell the output position: the earliestt tmstmp goes on the left, the 2nd lowest tmstmp goes next, the 3rd lowest tmptmp goes next, and so on. We can use the analytic ROW_NUMBER function to assing consectuive numbers (1 for lowest, 2 for 2nd lowest, 3 for 3rd lowest, and so on) to the different tmstmps for each trade_date. I'll assume you don't know how many of these there will be on any given trade_date, and there may be different numbers of them on different trade_dates in the same output. I'll assume you're using Oracle 10.
    If you have an unknown number of items, then string aggregation (concatenating all the values into one big sting column) is a lot easier and more robust than pivoting, so let's do it that way.
    Here's one way to do string aggregation:
    WITH     got_c_num     AS
         SELECT     adj_close
         ,     trade_date
         ,     ROW_NUMBER () OVER ( PARTITION BY  trade_date
                             ORDER BY        tmstmp
                           )     AS c_num
         FROM     ti
    --     WHERE     ...     -- if you need any filtering, put it here
    SELECT       trade_date
    ,       REPLACE ( SYS_CONNECT_BY_PATH ( TO_CHAR (adj_close, '999990.000')
                )          AS indices
    FROM       got_c_num
    WHERE       CONNECT_BY_ISLEAF     = 1
    START WITH     c_num          = 1
    CONNECT BY     c_num          = PRIOR c_num + 1
         AND     trade_date     = PRIOR trade_date
    ORDER BY  trade_date
    ;Output from your sample data:
    TRADE_DAT INDICES
    03-JAN-11       48.230     105.630     127.050CONNECT BY is used for parent-child realtionships of variable length within one table. Here, we have assigned c_num to be 1 for the first input row for each trade_date, 2 for the next, and so on. In the CONNECT BY uery above, we're saying that every parent-child-grandchild-... chain will start with a row numbered c_num=1, and that a row will be considered the child of another row if its c_num is 1 higher, and their trade_dates are the same. (That's what the START WITH and CONNECT BY clauses are doing.)
    SYS_CONNECT_BY_PATH gives a delimited list of items, starting from the root (the item with no parent, c_num=1) and showing the lineage down to each item in the original table that is descendedd from some root. That means we get 3 rows of output in this case: one showing just c_num=1, another with that same c_num=1 and c_num=2. and finally one with all 3 c_nums. We're only interested in the last one, the onme with no child, so the WHERE clause discards the others.
    By using TO_CHAR in SYS_CONNECT_BY_PATH, we get items that are padded to the same length. That way, when they are displayed, they will appear to line up in neat columns. SYS_CONNECT_BY_PATH reuires that you delimit the output items with some string that cannot possibly occur in the items themselves. I chose '/', but, since we don't want to see those '/'s, I used REPLACE to get rid of them once we were finished doing the SYS_CONNECT_BY_PATH.

  • Pivot Table Result

    Hi all,
    I am querying a table, which has four rows, with two col.
    Description Value
    A 5
    B 2
    C 1
    D 7
    Now I want result as follows in one row
    A B C D
    5 2 1 7
    can any one suggest me query
    Rgds

    not sure, this is about pivot not string aggregation !
    the best solution for string aggregation I have read on this forum is with XMLAgg :
    Re: how to display empno in a single row instead of displaying it vertically

  • 2 SQL questions

    Hi!
    I need 2 queries:
    1)
    I have a table b1 with date (string, yyyymmdd) and some other fields and a table b2 with date (string, yyyymmdd, referenced to b1), swid (ID of product) and pcs (no of ordered products). b1 are the base data of 1 order, b2 are the ordered products with reference to b1.
    What I need is a query that shows a statistic per month with count of all orders, all ordered pcs and all ordered pcs with swid='9016' like ...:
    month, sum_orders, sum_pcs, sum_9016
    2)
    I have a table b2 with date (string, yyyymmdd), swid (ID of product), pcs (no of ordered products), prc (price for 1 piece of the product).
    What I need is a statistic per year like ...:
    swid, sum_pcs_2008, sum_prc_2008, sum_pcs_2009, sum_prc_2009, ...
    I don't know if it's important but I have to use the queries in VB 2010 for an Oracle server database via ODBC.
    Thanks
    Peter

    Hi,
    Problem 1 is a Fan Trap , that is, a one-to-many relationship between tables, where you need aggregates from both tables. If you join the tables, then do the aggregates, then the parent rows that have multiple children will be counted multiple times. The solution is to do the aggregates on each table separately, using sub-queries. The solution above does the aggregates on b1 first, in the sub-query order_summary, and then does the aggregates on b2 in the main query:
    WITH     order_summary     AS
         SELECT       SUBSTR (dt, 1, 6)     AS month
         ,       COUNT (*)              AS sum_orders_permonth
         FROM       b1
         GROUP BY  SUBSTR (dt, 1, 6)
    SELECT       o.month
    ,       MIN (o.sum_orders_permonth)     AS sum_orders_permonth
    ,       SUM (b2.pcs)               AS sum_pcs_permonth
    ,       NVL ( SUM ( CASE
                              WHEN  b2.swid = 9016
                     THEN  bs.pcs
                          END
               , 0
               )                    AS sum_9016_permonth
    FROM       order_summary  o
    JOIN       b2              ON  SUBSTR (b2.dt, 1, 6)
    GROUP BY  o.month
    ORDER BY  o.month
    ;If you'd care to post CREATE TABLE and INSERT statments for your sample data, then I could test it.
    Problem 2 is a Pivot .
    The number of columns in a result set has to be hard-coded into the query when it is written and compiled.
    If you want to write something today that will have exactly as many columns as you have in the table next month (or any other point in the future), then you need Dynamic SQL . A simpler alternative is to use String Aggregation , where the output from a variable number of months actually goes into one big VARCHAR2 column, which is formatted to look like multiple columns.
    Both pivoting and string aggregation depend on your version of Oracle. The forum FAQ {message:id=9360005} covers several versions.
    {message:id=3527823} discusses options for pivoting a variable numebr of columns.
    If you'd like help, post you best attempt, CREATE TABLE and INSERT statements for some sample data, the results you want from that data, and your Oracle version.
    No kidding; you need to read the forum FAQ: {message:id=9360002}

  • Multiple rows into single row

    i have a table
    EID Code
    1 100
    1 101
    2 102
    1 104
    i want to get the output as Eid code code1 code2
    1 100 101 104
    2 102
    can anyone suggest on this?

    Not sure why so many are suggesting string aggregation techniques when the OP said...
    user10829046 wrote:
    i want to get the output as Eid code code1 code2
    1    100   101  104
    2    102 Clearly the output is required in seperate columns, not as one aggregated string.
    The solutions should relate to pivoting, not string aggregation.
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 1 EID, 100 code from dual union all
      3    select 1 ,101 from dual union all
      4    select 2 ,102 from dual union all
      5    select 1 ,104 from dual)
      6  --
      7  --
      8  select eid
      9        ,max(decode(rn, 1, code)) as code1
    10        ,max(decode(rn, 2, code)) as code2
    11        ,max(decode(rn, 3, code)) as code3
    12  from (select eid, code, row_number() over (partition by eid order by code) as rn
    13        from t
    14       )
    15  group by eid
    16* order by 1
    SQL> /
           EID      CODE1      CODE2      CODE3
             1        100        101        104
             2        102
    SQL>

  • Consolidating three rows into one

    Hello,
    I am struggling to figure this out and my googling hasn't quite led me to what I need. I have found some ideas such as sys_connect_by_path but I want to convert my three rows into columns (using one row), not concatenate them. I can not quite find the right thing or work it out. The code below gives me the columns I want but I can not figure out how to consolidate it onto one row. When I uncomment the group by line it doesn't like it as the role and emp fields are not group expressions. The values I wish to pivot are strings and not numbers (role).
    Would anybody be kind enough to help?? my brain has frozen!! :D
    Thanks very much
    Jon
    With t As
             Select 25840 id, 'Bob' emp, 'Primary' role  From dual Union All
             Select 25840, 'Jim', 'Secondary' From dual Union All
             Select 25840, 'Dave', 'Tertiary' From dual
        Select
        id
        ,decode(role,'Primary',emp) Prim
        ,decode(role,'Secondary',emp) Sec
        ,decode(role,'Tertiary',emp) Ter
        From
        t
        --group by id

    You just need to add a MAX and uncomment the GROUP BY
    SQL> ed
    Wrote file afiedt.buf
      1  With t As
      2           (
      3            Select 25840 id, 'Bob' emp, 'Primary' role  From dual Union All
      4            Select 25840, 'Jim', 'Secondary' From dual Union All
      5            Select 25840, 'Dave', 'Tertiary' From dual
      6           )
      7   Select
      8      id
      9      ,max(decode(role,'Primary',emp)) Prim
    10      ,max(decode(role,'Secondary',emp)) Sec
    11      ,max(decode(role,'Tertiary',emp)) Ter
    12    From t
    13*  group by id
    SQL> /
            ID PRIM SEC  TER
         25840 Bob  Jim  DavePersonally, I'd use a CASE rather than a DECODE, but that doesn't matter much.
    Justin

  • SQL Select grouping by value

    Hi ,
    I have an output after a join statement and i have output
    which is like below.
    I have an output containing two colums with same data except for the emp_depts and would like to write a select statement which will give a single row as opposed to two rows as below.
    Current out put view.
    emp_no emp_Name emp_Depts
    1 Test HR
    1 Test Finance
    Desired output.
    1 Test HR,Finance
    Can some one please help.

    If you are on 10g:
    SQL> create table mytable
      2  as
      3  select 1 emp_no, 'Test' emp_Name, 'HR' emp_Depts from dual union all
      4  select 1, 'Test', 'Finance' from dual
      5  /
    Tabel is aangemaakt.
    SQL> with t as
      2  ( select emp_no,emp_name,substr(ed,2) emp_depts,rn
      3      from mytable
      4     model
      5           partition by (emp_no,emp_name)
      6           dimension by (row_number() over (partition by emp_no order by null) rn)
      7           measures (cast(emp_depts as varchar2(50)) ed)
      8           rules
      9           ( ed[any] order by rn desc = ed[cv()+1] || ',' || ed[cv()]
    10           )
    11  )
    12  select emp_no
    13       , emp_name
    14       , emp_depts
    15    from t
    16   where rn = 1
    17  /
        EMP_NO EMP_ EMP_DEPTS
             1 Test HR,Finance
    1 rij is geselecteerd.And this technique is not called pivoting, but string aggregation. If you search for this term you will see some other techniques as well.
    Regards,
    Rob.

  • Pivoting string values( ,comma seperator) to separate columns(usingREG_EXP)

    <pre>
    I have column PART which contains string as shown below
    PART
    BMW PART,TEST PART,TEST PART,HYPER PART,HYPER PART,TESTINGNEWONE,TESTINGNEWONE,TESTINGNEWONE
    string has got comma separated, i need to project as individual columns like
    P1 P2 .... P8
    BMW PART TEST PART TESTINGEWONE
    how can it be done... (i think by using regular expressions it can be done but i am not aware of it can any one help)
    </pre>
    Thanks
    Naren

    Hi,
    Narendar.Vishwanatham wrote:
    thanks a lot for your query....
    cant we make it dynamically instead of hardcoding each columnThe number of columns produced by a query must be hard-coded into the query.
    Dynamic SQL means that you have some program (often another query) write all or part of the main query for you.
    The following thread has an example of a dynamic pivot in SQL*Plus:
    Help for a query to add columns
    The following thread discusses different options for dealing with an unknown number of columns after the pivot:
    Re: Report count and sum from many rows into many columns
    (and i guess the answer you gave is not possible to get with out using regular expresssions right !!!)No, you can get the same results using INSTR and SUBSTR.
    Whenever you ask for help, post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.
    Always mention what version of Oracle (and any other relevant tools) you're using. This is especially important with pivots; recent versions of Oracle have helpful new features.

  • ADF pivot table HeaderCellContext always returns String

    I am creating a pivot table using my own array of a custom class: PivotCell[][].
    Everything works fine and I am able to render data and cell wise colors etc.
    When I try to fetch value from headerCellContext, it returns string.
    It works with DataCellContext where I get my custom object.
    private class MyHeaderCellFormat extends CellFormat {
    public MyHeaderCellFormat(HeaderCellContext headerCellContext) {
    _headerCellContext = headerCellContext;
    Object value = _headerCellContext.getValue();
    Please help.

    Hi,
    according to the documentation, this should not be the case. As you can see, the documentation explicitly calls toString() for the string representation: http://docs.oracle.com/cd/E28389_01/web.1111/b31973/dv_crosstab.htm#CHDGCBIG . You can narrow down the problem by using the default cell format and see what this returns
    Frank

  • Error while opening central admin link after power pivot uninstall sp 2010?

    Error while any link opened in the cental admin
    example:http://server:port/_admin/WebApplicationList.aspx
    Required permissions cannot be acquired.
    ULS log when Config wizard ran 
      An exception of type System.IO.FileNotFoundException was thrown.  Additional exception information: Could not load file or assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
    or one of its dependencies. The system cannot find the file specified.
    System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
    File name: 'Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
       at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
       at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
       at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
       at Microsoft.SharePoint.PostSetupConfiguration.ReflectionHelper.InvokeConstructor(String assemblyQualifiedName, Type[] constructorSignature, Object[] constructorParameters)
       at Microsoft.SharePoint.PostSetupConfiguration.TaskCommon.ReflectionHelperInvokeConstructor(String assemblyQualifiedName, Type[] constructorSignature, Object[] constructorParameters, TaskBase task)
    the error same as the below article:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/7a06ebc8-ad8f-4b76-bc44-a8171fde6816/absolutely-sick-of-powerpivot-the-product-stinks-failed-to-find-assembly?forum=sqlkjpowerpointforsharepoint
    but any of the sollution did not work.
    Thanks
    Ravi
    Ravi

    I have uninstalled power pivot now the central adminlinks are working.
    but when i run configuration wizard it pups with error:
    Could not load file or assembly 'Microsoft.AnalysisServices.SharePoint.Integration'
    Can i delete follwoing key in the registery?
    The follwoing article asked to remove the key:
    http://social.technet.microsoft.com/Forums/en-US/487f18d4-32cf-4056-a6de-433f69bb7470/configuration-wizard-failed-to-find-assembly
    my registry entry
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServiceProxies\Microsoft.AnalysisServices.Sharepoint.Integration.EngineServiceProxy]
    "AssemblyQualifiedName"="Microsoft.AnalysisServices.Sharepoint.Integration.EngineServiceProxy, Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
    "ServiceProxyName"="MSOLAP$POWERPIVOT"
    Ravi

  • PIVOT table in SQL?

    Hello,
    I have a table with 3 columns, where person_id is unique id.
    <person_id> <event_type> <number_events>
    1. I need to transform this into a table with <person_id> <event_type1> <event_type2>.... <event_type-n>
    And under each column I need to fill the number_events for each event_type for that person_id
    2. Next step is to use that table and convert the same into % of number_events under each event_type, as % of total number_events for each id_member
    Thanks

    1. I need to transform this into a table with <person_id> <event_type1> <event_type2>.... <event_type-n>Problem as a SQL projection cannot be of an-unknown-number-of-columns-we-will-figure-it-out-at-run-time. Unless you use some funky PL/SQL coding to create an Advance SQL Data Type that sports a RTTI interface. And this is typically t0o complex for the "normal" PL/SQL developer that almost never use Advance SQL Data Types to create SQL classes, never mind using OCI calls to define PL/SQL methods for RTTI interfaces.
    You can of course have a column that is a collection - and a collection can contain any number of elements.
    Example:
    SQL> -- create a collection type of strings
    SQL> create or replace type TStrings as table of varchar2(4000);
      2  /                                                         
    Type created.
    SQL>
    SQL> col TYPE format a15
    SQL> col NAME_LIST format a100
    SQL>                         
    SQL> -- now perform a pivot using a collection where
    SQL> -- the collection can be 1..n                 
    SQL> select                                        
      2          t.object_type as "TYPE",              
      3          cast(   multiset(                     
      4                          select object_name from user_objects n where n.object_type = t.object_type
      5                  )                                                                                
      6                  as TStrings                                                                      
      7          ) as "NAME_LIST",                                                                        
      8          count(*) as "TOTAL"                                                                      
      9  from       user_objects t                                                                        
    10  group by                                                                                         
    11          t.object_type                                                                            
    12  order by 1                                                                                       
    13  /                                                                                                
    TYPE            NAME_LIST                                                                                                 TOTAL
    FUNCTION        TSTRINGS('TESTPIPE', 'TO_TMINOR', 'TO_SUB', 'AUTHENTICATE', 'CHECKSUM', 'FOOPIPE', 'WEBBROWSER', 'PR         19
                    EVENTDELETE', 'GETSTAT', 'GETHOSTNAME', 'FOOFUNC', 'TOKENISE', 'DYNAMICFUNCTION', 'STATS', 'POP3', '          
                    CALC', 'VPDBPOLICY', 'LISTTONUMBERS', 'TCPPING')                                                              
    INDEX           TSTRINGS('SYS_C0046436', 'SYS_C0046439', 'SYS_IOT_TOP_125320', 'SYS_IOT_TOP_125322', 'SYS_IOT_TOP_12         23
                    5324', 'SYS_IOT_TOP_125327', 'PK_STUFF', 'SYS_C0055439', 'SYS_C0076868', 'PATIENT_PK', 'SYS_C0055021          
                    ', 'INPATIENT_PK', 'SYS_C0055023', 'BED_PK', 'PK_TAB11', 'PK_ROUTERS', 'SYS_C0055202', 'PK_FOO_TAB',
                     'PK_FOO_UPDATE', 'PK_SERIALISE', 'SYS_C0058353', 'PK_EMP', 'PK_ANYCHART_TEMPLATES')
    LIBRARY         TSTRINGS('LIBC')                                                                                              1
    LOB             TSTRINGS('SYS_LOB0000125313C00031$$', 'SYS_LOB0000153382C00007$$', 'SYS_LOB0000141150C00002$$', 'SYS          6
                     _LOB0000205530C00001$$', 'SYS_LOB0000197183C00002$$', 'SYS_LOB0000209404C00002$$')

  • Pivoting using Model Clause Vs pivoting using Aggregate Fun(Case) statement

    Hi,
    I just wanted to know which option is better for pivoting the data if the data is like:
    Grp1 Grp2 Day_week Sales
    1 1 Sun 200
    1 1 Mon 100
    1 2 Sun 1000
    and so on...
    The output should be:
    Grp1 Grp2 Sun Mon ......
    1 1 200 100.....
    1 2 1000 NULL....
    I have tested the same using sum(decode...) method and also model clause:
    select grp1, grp2, sum(decode(day_week,'SUN',sales)) SUNDAY , sum(decode(day_week,'MON',sales)) MONDAY from pivot
    group by grp1, grp2
    order by grp1, grp2
    select grp1, grp2, sun , mon, tue, wed, thr, fri, sat
    from pivot
    model -- UNIQUE SINGLE REFERENCE
    return updated rows
    partition by (grp1, grp2)
    dimension by ( day_week)
    measures( result, 0 mon, 0 tue, 0 wed, 0 thr,0 fri, 0 sat, 0 sun)
    RULES upsert
    mon[0]= sales['MON'],
    tue[0]= sales['TUE'],
    wed[0]= sales['WED'],
    thr[0]= sales['THR'],
    fri[0]= sales['FRI'],
    sat[0]= sales['SAT'],
    sun[0]= sales['SUN']
    ) order by grp1, grp2
    There are 4K records in the table. The first query is taking app (.125 seconds) and the second query (.230 seconds).
    Pls tell how the model clause can give better performance and I want to use it for pivoting in all my APIs.
    Regards
    Rajiv

    > I read somewhere while searching on net.
    And now you can't find it anymore? I wouldn't believe anything you read somewhere while searching on net, unless it has some kind of proof attached.
    > You pls tell is it so or it depends upon volume of data.
    Also i tested on some data and reults were better in
    case of using normal startegy rather than model.(case
    provided above).
    So you have tested it yourself already. The model clause is great in a few cases (string aggregation, calculating values based on calculated values), but this doesn't seem to be one of them. On 11g you might want to consider the PIVOT operator.
    Regards,
    Rob.

  • March's TechNet Wiki Power Pivot Guru Winners announced!!

    The results for March'sTechNet
    Guru competition have been posted!
    http://blogs.technet.com/b/wikininjas/archive/2014/04/17/the-microsoft-technet-guru-awards-march-2014.aspx <- results page!
    Congratulations to all our new Gurus for March!
    We will be interviewing some of the winners and highlighting their achievements, as the month unfolds.
    Below is a summary of the medal winners, the last column being a few of the comments from the judges.
    Unfortunately, runners up and their judge feedback comments had to be trimmed from THIS post, to fit into the forum's 60,000 character limit, however the full version is shown in the link above.
    Some articles only just missed out, so we may be returning to discuss those too, in future blogs.
     BizTalk Technical Guru - March 2014  
    Tomasso Groenendijk
    Using BAM in the ESB Toolkit
    Ed Price: "Incredibly valuable and very well written! Great article!"
    Mandi Ohlinger: "A custom BAM dashboard - LOVE it! Another great ESB addition to the Wiki."
    TGN: "Nice one, I really liked this one, explains how to use the ESB together with BAM, great work and well explained!"
    Steef-Jan Wiggers
    Windows Azure BizTalk Services: Pulling Messages from a Service Bus Queue
    Ed Price: "This is amazingly well written with beautiful images and formatting. Great job!"
    TGN: "Azure, Azure, Azure! Nice one Steef-Jan, people are waiting on articles like this. Good job, and thanks for the contribution!"
    Mandi Ohlinger: "A very informative How To. Screen shots are very helpful."
    boatseller
    Detecting a Missing Message
    Mandi Ohlinger: "GREAT addition to the Wiki and to any user who suspects missing messages. The BizTalk support team can use this orchestration. "
    Ed Price: "I love the visuals on the orchestration implementation! Important topic!"
    TGN: "Nice article, great to see a solution to detect missing files."
     Forefront Identity Manager Technical Guru - March 2014  
    Eihab Isaac
    FIM 2010 R2 BHOLD: Non-BHOLD Approval Process
    Ed Price: "Very thorough explanations! Great formatting and colors on the tables and code snippets! And the images are also helpful!"
    PG: "Nice article, we need more of these."
    Micah Rowland
    FIM:How To Use PowerShell to View a Metaverse Object's Connector's Attribututes
    Side By Side
    PG: "Nice article, nice format. well written"
    Ed Price: "Good code snippet and use of code comments. Could use more explanations and maybe breaking the code into sections with more information about each section. Good job!"
    Giriraj Singh
    FIM:Delete Bulk Expected Rule Entries Using FIM OTB features
    Ed Price: "Good procedural steps! It could benefit from more explanations, a grammar pass, and some images. Good article!"
    PG: "Short but nice article."
     SharePoint 2010 / 2013 Technical Guru - March 2014  
    Matthew Yarlett
    SharePoint: Use PowerShell to find Fields using a Managed Metadata TermSet
    Jinchun Chen: "Good article."
    Ed Price: "Although this is Matt's shorter article this month, this is an incredibly important topic, and the code is perfect! As Dan says in the comments: "Matthew Yarlett has done it again!! IMHO when it comes to SharePoint powershell
    you are second to none." This is a great article!" 
    Rahul A Shinde
    SharePoint 2013: Deploy and apply theme to SharePoint sites with PowerShell
    Ed Price: "Fantastic explanations and use of images!" 
    Matthew Yarlett
    SharePoint: Testing Email Alerts in UAT and DEV Environments
    Jinchun Chen: "Nice! It can be used for troubleshooting SharePoint Incoming/Outgoing related issues too."
    Ed Price: "Wow! This article is astonishingly thorough!"
     Small Basic Technical Guru - March 2014  
    Nonki Takahashi
    Small Basic: Centering Text in Graphics Window
    RZ: "Clearly written explanation with nice graphics to go with it."
    Ed Price: "I love having the three options like this! And the images really bring it to life! The links to the shared programs (with their source code) really help if you want to dig deeper and learn more!"
    Nonki Takahashi
    Small Basic Known Issue: 23589
    - Controls.GetTextBoxText() Returns CR+LF as Newline from Multi-Line Text Box in Local but CR in Remote
    RZ: "Bugs are always hard to track down, especially the unknown unknowns :( Good job on hunting it down!"
    Ed Price: "This acts as a valuable KB article! Great addition to the troubleshooting library!"
    Nonki Takahashi
    Small Basic: Expression
    RZ: "Good introduction to expressions"
    Ed Price: "Short and sweet intro to Expressions. Thanks, Nonki!"
     SQL BI and Power BI Technical Guru - March 2014  
    Michael Amadi
    A Practical Example of How to Apply Power Query Data
    Transformations on Structured and Unstructured Datasets
    NN: "This is a terrific tutorial on Power Pivot with very helpful images. Great article"
    Ed Price: "This is a fantastic combination of Power Query and Power Pivot... a valuable contribution!"
     SQL Server General and Database Engine Technical Guru - March 2014  
    chandra sekhar pathivada
    managing database backups across all the instances without maintenance plan
    Samuel Lester: "Chandra, outstanding contribution and information! Your SSIS package handles many of the shortcomings of Maintenance Plans. MPs were originally created to assist DBAs with the more common administrative
    tasks, but as the scale continues to grow across enterprise environments, we're all forced to write our own enhanced versions such as this. Thanks for the addition and please do add to the Gallery if you haven't yet."
    Jinchun Chen: "Nice. It is suggested to add error outputs in the package to handler unexpected errors."
    NN: "Good article. The SSIS solution can use a bit more explanation. Also See Also section is missing"
    DRC: "This is good article, The only this which can be corrected is : ==> This can be achieved using “maintenance Cleanup Task • Maintenance Plan has a control flow item “maintenance Cleanup Task” to delete the old backup files based
    on age of the backup, but it creates the problem when it deletes the full database backups based on n no.of days leaving all the dependent intermediate differential and transaction logs which are useless. "
    Shanky
    Understanding Logging in Tempdb.Is Tempdb re-created or rebuilt after SQL
    Server restart
    NN: "Very good article with an interesting analysis"
    DRC: "This article is good and provides lots of detailed information along with sample query and screenshot. The screenshot of few need few more details (files of model are missing) This article can be broken down into 2 1) understanding
    tempdb recreation 2) Logging in Tempdb 1) understanding tempdb recreation:- This is not concluded properly. The article doesnt talk about the physical files which are recreated even if we delete the tempdb files "
    Samuel Lester: "Shanky, very nice article on the internals of TempDB! It was tough judging this month as both articles were very informative contributions!" 
     System Center Technical Guru - March 2014  
    Mr X
    How to manage VM pinning within a Hyper-V cluster by
    combining the use of System Center VMM and Orchestrator
    Ed Price: "Mr. X, this is another incredibly thorough article! Fantastic job!"
    Idan Vexler
    Create Custom XML For OSD In SCCM  
    Ed Price: "Love the list of requirements! Very thorough in dividing each step!"
    Omar Lopez (loplim)
    SCOM 2012 - Create Alert / Monitor Based on Windows event ( Administrator login
    alert )
    Ed Price: "Good use of images. Could use a TOC with sections and more descriptions. Good job!"
     Transact-SQL Technical Guru - March 2014  
    Jayakumaur (JK)
    Understanding IDENTITY in SQL Server
    Ed Price: "Wow, what a competitive month! This article is amazing, with thorough explanations in each section!"
    Richard Mueller: "A good tutorial on an important feature of T-SQL."
    Durval Ramos
    Paging a Query with SQL Server
    Ed Price: "Durval's article is fantastically thorough and easy to follow!"
    Richard Mueller: "Very useful concept when populating controls from a query, which should improve performance. I like the images. Well done."
    Naomi N
    T-SQL: Split String with a Twist
    Richard Mueller: "Very intersting problem with an original solution."
    Ed Price: "A very powerful and well-articulated solution from Naomi!"
     Visual Basic Technical Guru - March 2014  
    The Thinker 
    Exporting and Importing Wireless Settings Using Netsh in VB.NET
    SB: "Code could be formatted better, task is something I can see as potentially useful although I would prefer a bit more narrative description and comments in the code explaining why it was done a certain
    way, although the code is simple enough to work through." 
    MR: "Great tool code!" 
    Ed Price: "This is a good contribution! One way to improve an article like this is to explain the parts of the code more in depth, as a way to introduce each snippet (and maybe dividing a block up more). Then you could link to the Gallery
    iteam if the reader wants to access the entire snippet at once. The images are also very helpful! Great job!" 
    Richard Mueller: "Perhaps this code should be in the gallery. There should be more explanation in a Wiki."
     Visual C# Technical Guru - March 2014  
    João Sousa
    ASP.NET WebAPI 2 - Stream Windows Azure blobs
    NN: "Very nice tutorial and also can be downloaded from the Gallery"
    Ed Price: "I love to see this ASP.NET content! Each step is very clear! Great code formatting!"
    Raghunathan S
    C# Code Compilation at Runtime from C# Windows Forms Application
    Ed Price: "Good descriptions and code formatting. It could benefit from a TOC. Great article!"
    NN: "This looks like an interesting article, but too short and the code is hard to read in its present format"
    Raghunathan S
    Creating a Simple logging class with System.Diagnostics namespace in C#
    NN: "Good article, but too short"
    Ed Price: "This is a pretty good article. It could benefit from a TOC and more descriptions around what the code is doing and why. Good job!"
     Wiki and Portals Technical Guru - March 2014  
    Matthew Yarlett
    Wiki: Basic Image Formatting using Pixlr
    BL: "This deserves credit as much for the idea as for the actual article - many authors contribute from computers that may not have authoring tools installed and this simple online solution has the potential to iprove
    quality a lot."
    Richard Mueller: "Excellent explanation of a useful tool for Wiki authors. A "See Also" section would be useful."
    PG: "Nice artilce, well done, nice layout. Great!"
    NN: "Good article"
    Durval Ramos
    VBA & VBS Portal
    NN: "Very good new portal about VBA. Introduction may be improved a bit"
    Richard Mueller: "A great collection of Wiki articles. Excellent use of recommended features in a Wiki article."
    PG: "Nice article good start!"
    BL: "Another great initial compilation of relevant resources. Would be very interested in seeing how this develop over time."
    Mr X
    Wiki: System Center Orchestrator Portal
    NN: "Good new portal. Missing See Also section with links to other portals"
    Richard Mueller: "A good collection of articles. This Portal adds a lot to the TechNet Wiki."
    PG: "Nice and neat article? Suggestion to add more references to related articles and platforms on Wiki."
    BL: "great initial compilation of SC Orchestrator resources. Hoping this will grow over time as the product has a few other active Wiki contributors."
     Windows Phone and Windows Store Apps Technical Guru - March 2014  
    Isham Mohamed
    Pin Windows Phone 8 app to start screen on first launch.
    Peter Laker: "A very useful and informative article! Also, Nice use of fonts and images."
    Ed Price: "Good explanation, but it could benefit from a TOC and tweaked formatting. Good job!"
    Ibraheem Osama Mohamed
    Coming from an asp.net background, let’s build our first Windows Store Application
    Ed Price: "Great job on the formatting, explanations, and code snippets!"
    Peter Laker: "Excellent primer for those moving from asp.net and all beginners."
    mcosmin
    The Performance Analyzer Paradox
    Ed Price: "This is a good philosophical article, but it would be richer with examples and visuals. "
    Peter Laker: "Nice story, good reading, very worthy entry and gratefully received!"
     Windows Presentation Foundation (WPF) Technical Guru - March 2014  
    Magnus (MM8)
    WPF/MVVM: Handling Changes To Dependency Properties In The View
    Ed Price: "Nice, thorough topic with good explanations! Could benefit from code formatting. Great article!"
    Peter Laker: "A nice primer on a fundamental aspect of xaml. Great layout, images, descriptions, etc."
    dev hedgehog
    Trick To Use StaticResource With Path
    Peter Laker: "A very useful and commonly pondered subject. Thanks for a great contribution!"
    Ed Price: "This is a great solution with good code formatting and code comments!"
     Windows Server Technical Guru - March 2014  
    Mr X
    How to manage your DC/DNS servers with dynamic IPs in Windows Azure
    JM: "This is an excellent article, however you need to change all instances of the term "on-promise" to "on-premise.""
    JH: "really detailed, very complete with scripts added"
    Richard Mueller: "This might be the best article I have judged. Code formatting could be improved, but otherwise an outstanding contribution."
    Mr X
    How to assign a private Static IP to a Windows Azure VM
    JH: "excellent, concise, good topic"
    Richard Mueller: "Excellent documentation of the use of very new tools to manage IP addresses."
    JM: "Another excellent article, thanks much for your contributions!"
    Mahdi Tehrani
    Customize DST time zone configuration across the forest with GPO
    JM: "This is an excellent article, however you need to change all instances of the term "Daylight Time Saving" to "Daylight Savings Time.""
    JH: "good info, great illustrations and writing"
    Richard Mueller: "Original work for an tricky problem. I think the script should run as a Startup script instead of a Logon script on the clients. A "See Also" section and links would help."
    ----------------- 8< -------------------
    As mentioned above, runners up and their judge feedback were removed from this forum post, to fit into the forum's 60,000 character limit.
    A great big thank you to EVERYONE who contributed an article to last month's competition.
    Read all about THIS month's competition [usually in a stickied post] at the top of this forum, otherwise there is usually a list of forum links for this month's theme/announcement at the bottom of the submission page below:
    http://social.technet.microsoft.com/wiki/contents/articles/23837.technet-guru-contributions-for-april-2014.aspx
    Best regards,
    Pete Laker
    More about the TechNet Guru Awards:
    TechNet Guru Competitions
    #PEJL
    Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to the one and only
    TechNet Wiki, for future generations to benefit from! You'll never get archived again!
    If you are a member of any user groups, please make sure you list them in the
    Microsoft User Groups Portal. Microsoft are trying to help promote your groups, and collating them here is the first step.

    Congrats to Michael:
     SQL BI and Power BI Technical Guru - March 2014  
    Michael Amadi
    A Practical Example of How to Apply Power Query Data
    Transformations on Structured and Unstructured Datasets
    NN: "This is a terrific tutorial on Power Pivot with very helpful images. Great article"
    Ed Price: "This is a fantastic combination of Power Query and Power Pivot... a valuable contribution!"
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Excel Pivot (molap) will not refresh from an SSAS box that is not part of the Farm

    I have spent hours trying to get this working going through many links.  One of the best ones is this.
    http://whitepages.unlimitedviz.com/2010/12/connecting-to-cubes-and-external-data-with-excel-in-sharepoint/
    However even after doing all of this it is still not working.  Here is my set up.  I have a sharepoint 2013.  I am trying to connect to my DW SSAS server that is on a different domain and not part of the farm.  Everything else seems to
    work but excel.  I have power view connecting and creating great reports with refesh working perfect.  I have performance point working.  I have Reporting Services working.  We installed adventureworks on the local SSAS farm version and
    excel is working with this and refreshed just fine.  I can ceate and excel report and save it to sharepoint but when I open it I get the famous error.
    An error occurred during an attempt to establish a connection to the external data source. The following connections failed to refresh:
    I can open in excel and then refresh all from excel and all works fine.  I do not want my users to have to go through this.  They should be able to use excel in sharepoint.  Any ideas on what I am missing.  I have tried to follow exactly
    what the link above says but still not working.
    Ken Craig

    The first article is checking to make sure power pivot is installed and local ssas is running. This could not be an issue since like I mentioned I can create a Excel report to the local farm version of ssas and it opens and refreshed fine.  That
    would mean that power pivot is installed and the services are running right:)?
    The second article I have done over and over and I am pretty sure this works.  Again I can export to excel and it works just fine meaning my Data source is valid right?  yes I have chosen "none" as well.
    The third article talks about the different viewers.  Mine is using
    xlviewer.aspx so I would assume this is not the issue. 
    Here is what I am seeing in the logs but I am not sure what they are saying.  I used uls view somewhat like you would profiler. I started it tried to open excel and then stopped it.  Below are logs that look like they pertain to this action.
    ConnectionManager.GetConnection: Failed to create new connection, exception=Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException: Exception of type 'Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException' was thrown.   
    at Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionInterop.InitConnection()   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.<>c__DisplayClass8.<CreateConnection>b__5()   
    at Microsoft.Office.Excel.Server.CalculationServer.CredentialsTrustedSubsystem.TryExecuteImpersonated(ExecuteImpersonatedMethod method)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.CreateConnection(Credentials credentials, ConnectionInfo connectionInfo, Int32 keyLcid, Uri workbookUrl, Boolean auditConnection, SessionId sessionId), sessionId=1.V23.297S76/z2k/Evl+S78bqiKj14.5.en-US5.en-US36.5a800c6f-758b-44e2-a092-e592f15e09771.A1.N,
    connectionString=Provider=MSOLAP.5;Integrated Security=SSPI;Persist Security Info=True;Data Source=BIL-BIRSTDB\ASADMIN;Initial Catalog=Ecomm OLAP pool count=0
    ConnectionManager.GetConnection: Caught an exception: Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException: Exception of type 'Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException' was thrown.   
    at Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionInterop.InitConnection()   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.<>c__DisplayClass8.<CreateConnection>b__5()   
    at Microsoft.Office.Excel.Server.CalculationServer.CredentialsTrustedSubsystem.TryExecuteImpersonated(ExecuteImpersonatedMethod method)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.CreateConnection(Credentials credentials, ConnectionInfo connectionInfo, Int32 keyLcid, Uri workbookUrl, Boolean auditConnection, SessionId sessionId)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.CreateConnectionAndAddToList(ConnectionRequest connectionRequest, ExtendedConnectionInfo extendedConnInfo, Credentials credentials, Boolean auditConnection, Int32 keyLcid, ConnectionKey
    connectionKey, AutoReaderWriterLock autoPoolLock, Connection& connection, ConnectionList& connectionList)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.GetConnection(ConnectionRequest connectionRequest, ExtendedConnectionInfo extendedConnInfo, Credentials credentials, Int64 privateConnectionId, Boolean auditConnection)
    Refresh failed for 'BIL-BIRSTDB_ASADMIN Ecomm OLAP Report' in the workbook 'http://eagleviewportal/BusinessIntelligenceCenter/Templates/Ecomm Report Power Pivot Default.xlsx'. [Session: 1.V23.297S76/z2k/Evl+S78bqiKj14.5.en-US5.en-US36.5a800c6f-758b-44e2-a092-e592f15e09771.A1.N
    User: 0#.w|hqeagleview\ken.craig]
    ExternalSource.ValidateConnection: Unable to get a connection: Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException: Exception of type 'Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionException' was thrown.   
    at Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionInterop.InitConnection()   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.<>c__DisplayClass8.<CreateConnection>b__5()   
    at Microsoft.Office.Excel.Server.CalculationServer.CredentialsTrustedSubsystem.TryExecuteImpersonated(ExecuteImpersonatedMethod method)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.CreateConnection(Credentials credentials, ConnectionInfo connectionInfo, Int32 keyLcid, Uri workbookUrl, Boolean auditConnection, SessionId sessionId)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.CreateConnectionAndAddToList(ConnectionRequest connectionRequest, ExtendedConnectionInfo extendedConnInfo, Credentials credentials, Boolean auditConnection, Int32 keyLcid, ConnectionKey
    connectionKey, AutoReaderWriterLock autoPoolLock, Connection& connection, ConnectionList& connectionList)   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionManager.GetConnection(ConnectionRequest connectionRequest, ExtendedConnectionInfo extendedConnInfo, Credentials credentials, Int64 privateConnectionId, Boolean auditConnection)   
    at Microsoft.Office.Excel.Server.CalculationServer.ExternalSource.TryGetValidatedConnection(Request request, ConnectionRequest connectionRequest, ExternalDataScenario scenario, Credentials credentials, ExtendedConnectionInfo extendedConnectionInfo, Int64
    privateConnectionId, Boolean shouldReportFailure, Connection& connectionOut). sessionId=1.V23.297S76/z2k/Evl+S78bqiKj14.5.en-US5.en-US36.5a800c6f-758b-44e2-a092-e592f15e09771.A1.N, externalSource=BIL-BIRSTDB_ASADMIN Ecomm OLAP Report
    ExternalDataUtility.ExecuteOperation: We exhausted all available connection information. Exception: Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionInfoException: Exception of type 'Microsoft.Office.Excel.Server.CalculationServer.Interop.ConnectionInfoException'
    was thrown.   
    at Microsoft.Office.Excel.Server.CalculationServer.ConnectionInfoManager.GetConnectionInfo(Request request, String connectionName, ExtendedConnectionInfo extendedConnInfo, Boolean& shouldReportFailure)   
    at Microsoft.Office.Excel.Server.CalculationServer.ExternalDataUtility.GetExtendedConnectionInfo(IExternalDataObject extObject, ConnectionInfoManager connectionInfoManager, Request request, Int32 externalSourceIndex, Boolean ignoreErrors, ExternalDataScenario
    scenario, Exception& lastException, Boolean& shouldReportFailure)   
    at Microsoft.Office.Excel.Server.CalculationServer.ExternalSource.GetConnection(ExternalKey externalKey, Int32 externalSourceIndex, ExternalQueryKey externalQueryKey, ConnectionRequest connectionRequest, Int64 privateConnectionId, ExternalDataScenario scenario,
    Boolean prepare), Data Connection Name: BIL-BIRSTDB_ASADMIN Ecomm OLAP Report, SessionId: 1.V23.297S76/z2k/Evl+S78bqiKj14.5.en-US5.en-US36.5a800c6f-758b-44e2-a092-e592f15e09771.A1.N, UserId: 0#.w|hqeagleview\ken.craig
    Ken Craig

Maybe you are looking for

  • Can I use one CC subscription on both my PC desktop and Mac notebook?

    Adobe has long permitted a single purchase of products like CS6 to be installed on two machines (PC desktop plus PC notebook) for use by the same user at different times. 1.  Is that still permitted with a CC subscription? 2.  What if the desktop is

  • How to update from itunes 6 to 8 or 9 under 10.4?

    Hi, As my title says really, i'm running itunes 6 on my 1.25ghz powerbook G4 and want the latest version i can run. Where do i get it from? Thanks

  • Can I install Tiger on external drive with OS9 on internal?

    I bought and plan to install OS X 10.4.3, but will continue to use OS 9.2.2 about 95% of the time because I can't afford to update all 3rd-party software at this time, so I want to start up in 9.2.2 usually. Can I install 10.4.3 on a partition of my

  • Displaying pdf file in a jsp page...

    hi, I want to display a pdf document in a jsp page. i got that pdf file from a servlet class(MVC Architecture) through session. now my problem is to display that pdf file in my jsp page. can anyone give me a idea to solve this problem..

  • Simple Edits to Adobe Illustrator and Photoshop files

    We need to be able to make simple edits to Photoshop and Illustrator files -- e.g. fixing typos. I am hesitant to buy a copy of both programs at over $1000 when we will be using 0.01% of the program! Desire is to open, make edit, save in original for