2.1 Autogenerate GROUP BY and anlaytic functions

I love the auto-generate group by feature, but I use analytic functions more frequently these days and that makes the feature a little less usable.
Would it be possible for SQLDeveloper to remove a group by that is automatically added if when the OVER clause follows an aggregate? Or have it generate after the cursor has moved to a new line, giving the auto-complete time to decide if it's an aggregate or an analytic?

I love the auto-generate group by feature, but I use analytic functions more frequently these days and that makes the feature a little less usable.
Would it be possible for SQLDeveloper to remove a group by that is automatically added if when the OVER clause follows an aggregate? Or have it generate after the cursor has moved to a new line, giving the auto-complete time to decide if it's an aggregate or an analytic?

Similar Messages

  • How to "group by" and use functions on grouped records

    I group rows and wantto select the max date row in date column. The other columns can include same data in its rows, thus i wantto select distinct data in the rows. I use the following query, but ir throws the message "ORA-00936: missing expression."
    select max(t2.tarih), distinct (t1.ihlkodu),distinct(t1.ihlaltktgkodu), distinct(t1.kuladi),distinct(t4.ad) from ihale_katilimcilar t1, ihale_hareket t2, ihale_sirket t4
    where t1.id_iliski=t2.id_iliski and t1.kuladi=t4.kullaniciadi and t1.ihlkodu=145 and t1.ihlaltktgkodu=135 and t1.aktif=1
    group by t2.tarih, t1.ihlkodu,t1.ihlaltktgkodu,t1.kuladi,t4.ad
    Here t2.tarih is a field of date and i wantto select the max of this.
    t1.ihlkodu has all the same data in its rows.
    t1.ihlaltktgkodu too has all the same data in its rows.
    t1.kuladi may have ,let me say, 5 rows of same data and 6 rows of another same data in this 6 but different then the first 5 rows of same data. That is, the content of the 6 and 5 is the same in 6 and 5 but different then each other.
    and finally[b] t4.ad too may have ,let me say, 5 rows of same data and 6 rows of another same data in this 6 but different then the first 5 rows of same data.(That is, the content of the 6 and 5 is the same in 6 and 5 but different then each other)
    How could i group them?

    Here is the script of tables:
    -- Create table
    create table IHALE_SIRKET
    SRKTKODU NUMBER not null,
    AD VARCHAR2(30) not null,
    ADRES VARCHAR2(50),
    TEL1 VARCHAR2(15),
    TEL2 VARCHAR2(15),
    FAX VARCHAR2(15),
    EMAIL VARCHAR2(20),
    KARALISTE NUMBER default -1,
    AKTIF NUMBER(1) default -1,
    SICILNO VARCHAR2(20) not null,
    VERGINO VARCHAR2(20) not null,
    TICSICILGAZSAYI VARCHAR2(10) not null,
    TICSICILGAZTARIH DATE not null,
    ODASICILNO VARCHAR2(20),
    TESCILTARIHI DATE,
    SERMAYE VARCHAR2(20),
    DERECE NUMBER(2),
    ODAKAYITTARIHI DATE,
    KULLANICIADI VARCHAR2(15)
    tablespace USERS
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- Create/Recreate primary, unique and foreign key constraints
    alter table IHALE_SIRKET
    add constraint CONSTRAINT_SRKTKODUPK primary key (SRKTKODU);
    -- Create/Recreate indexes
    create unique index IHALE_SIRKET_SRKTKODU on IHALE_SIRKET (SRKTKODU)
    tablespace USERS
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- Create table
    create table IHALE_KATILIMCILAR
    KULADI VARCHAR2(20),
    SONUC NUMBER(1),
    AKTIF NUMBER(1) default 1,
    SRKTKODU VARCHAR2(10) not null,
    SONBULUNMAZAMANI DATE default sysdate,
    SIRA NUMBER(1) default 0,
    EKSURETALEP VARCHAR2(50),
    ID NUMBER(6) not null,
    IHLKODU NUMBER not null,
    IHLALTKTGKODU VARCHAR2(10) not null,
    ID_ILISKI NUMBER
    tablespace USERS
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- Create/Recreate primary, unique and foreign key constraints
    alter table IHALE_KATILIMCILAR
    add constraint CONSTRAINT_IHLKTLMIDPK primary key (ID)
    using index
    tablespace USERS
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- -- -- Create table
    create table IHALE_HAREKET
    ID_ILISKI NUMBER not null,
    TEKLIF VARCHAR2(15) not null,
    TARIH DATE default sysdate,
    ID NUMBER not null
    tablespace USERS
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    -- Create/Recreate primary, unique and foreign key constraints
    alter table IHALE_HAREKET
    add constraint CONSTRAINT_IHLHAREKETPK primary key (ID)
    using index
    tablespace USERS
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    initial 64K
    minextents 1
    maxextents unlimited
    Here is the content of those tables:
    prompt Loading IHALE_HAREKET...
    insert into IHALE_HAREKET (ID_ILISKI, TEKLIF, TARIH, ID)
    values (189, '1400YTL', to_date('12-02-2008 14:35:07', 'dd-mm-yyyy hh24:mi:ss'), 1);
    insert into IHALE_HAREKET (ID_ILISKI, TEKLIF, TARIH, ID)
    values (203, '1200YTL', to_date('12-02-2008 16:03:16', 'dd-mm-yyyy hh24:mi:ss'), 2);
    insert into IHALE_HAREKET (ID_ILISKI, TEKLIF, TARIH, ID)
    values (203, '1100YTL', to_date('12-02-2008 16:03:16', 'dd-mm-yyyy hh24:mi:ss'), 3);
    insert into IHALE_HAREKET (ID_ILISKI, TEKLIF, TARIH, ID)
    values (189, '1500 YTL', to_date('12-02-2008 14:34:30', 'dd-mm-yyyy hh24:mi:ss'), 0);
    prompt 4 records loaded
    prompt Loading IHALE_KATILIMCILAR...
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '42', to_date('12-02-2008 13:33:32', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 63, 141, '134', 191);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '46', to_date('12-02-2008 13:33:32', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 64, 141, '134', 192);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values ('KEM.ESM', null, 1, '44', to_date('12-02-2008 11:00:41', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 61, 145, '135', 189);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '45', to_date('12-02-2008 13:33:42', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 69, 141, '133', 197);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '42', to_date('12-02-2008 13:33:36', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 65, 141, '132', 193);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '45', to_date('12-02-2008 13:33:36', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 66, 141, '132', 194);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '46', to_date('12-02-2008 13:33:36', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 67, 141, '132', 195);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '42', to_date('12-02-2008 13:33:42', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 68, 141, '133', 196);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '44', to_date('12-02-2008 13:34:23', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 70, 142, '252', 198);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '45', to_date('12-02-2008 13:34:23', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 71, 142, '252', 199);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '44', to_date('12-02-2008 13:34:40', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 72, 143, '253', 200);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '46', to_date('12-02-2008 13:34:40', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 73, 143, '253', 201);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '45', to_date('12-02-2008 11:00:38', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 60, 145, '136', 188);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values (null, null, 0, '44', to_date('12-02-2008 15:59:21', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 74, 145, '136', 202);
    insert into IHALE_KATILIMCILAR (KULADI, SONUC, AKTIF, SRKTKODU, SONBULUNMAZAMANI, SIRA, EKSURETALEP, ID, IHLKODU, IHLALTKTGKODU, ID_ILISKI)
    values ('KE.ES', null, 1, '45', to_date('12-02-2008 15:59:25', 'dd-mm-yyyy hh24:mi:ss'), 0, null, 75, 145, '135', 203);
    commit;
    prompt 15 records loaded
    prompt Loading IHALE_SIRKET...
    insert into IHALE_SIRKET (SRKTKODU, AD, ADRES, TEL1, TEL2, FAX, EMAIL, KARALISTE, AKTIF, SICILNO, VERGINO, TICSICILGAZSAYI, TICSICILGAZTARIH, ODASICILNO, TESCILTARIHI, SERMAYE, DERECE, ODAKAYITTARIHI, KULLANICIADI)
    values (42, 'KEMMM', 'asddd', '03123456444', '03123456444', '03123456444', '[email protected]', 0, 1, '325999444', '234999444', '34599944', to_date('04-02-2008', 'dd-mm-yyyy'), '23/29444', to_date('04-02-2008', 'dd-mm-yyyy'), '4.000.000.11YTL', 1, to_date('04-02-2008', 'dd-mm-yyyy'), null);
    insert into IHALE_SIRKET (SRKTKODU, AD, ADRES, TEL1, TEL2, FAX, EMAIL, KARALISTE, AKTIF, SICILNO, VERGINO, TICSICILGAZSAYI, TICSICILGAZTARIH, ODASICILNO, TESCILTARIHI, SERMAYE, DERECE, ODAKAYITTARIHI, KULLANICIADI)
    values (46, 'MLK', 'fgh', '456', '456', '456', '[email protected]', 0, 1, '2346', '2346', '2346', to_date('27-01-2008', 'dd-mm-yyyy'), '2346', to_date('25-01-2008', 'dd-mm-yyyy'), '2346', 1, to_date('22-01-2008', 'dd-mm-yyyy'), null);
    insert into IHALE_SIRKET (SRKTKODU, AD, ADRES, TEL1, TEL2, FAX, EMAIL, KARALISTE, AKTIF, SICILNO, VERGINO, TICSICILGAZSAYI, TICSICILGAZTARIH, ODASICILNO, TESCILTARIHI, SERMAYE, DERECE, ODAKAYITTARIHI, KULLANICIADI)
    values (44, 'ASD', 'asd', '123', '123', '123', '[email protected]', 0, 1, '123', '123', '123', to_date('10-01-2008', 'dd-mm-yyyy'), '123', to_date('17-01-2008', 'dd-mm-yyyy'), '123', 1, to_date('11-01-2008', 'dd-mm-yyyy'), 'KEM.ESM');
    insert into IHALE_SIRKET (SRKTKODU, AD, ADRES, TEL1, TEL2, FAX, EMAIL, KARALISTE, AKTIF, SICILNO, VERGINO, TICSICILGAZSAYI, TICSICILGAZTARIH, ODASICILNO, TESCILTARIHI, SERMAYE, DERECE, ODAKAYITTARIHI, KULLANICIADI)
    values (45, 'JKL', 'jkl', '234', '234', '345', '[email protected]', 0, 1, '234', '234', '234', to_date('04-01-2008', 'dd-mm-yyyy'), '234', to_date('27-01-2008', 'dd-mm-yyyy'), '234', 2, to_date('19-01-2008', 'dd-mm-yyyy'), 'KE.ES');
    When i use the following sql:
    select t2.teklif, t2.tarih, t1.ihlkodu, t1.ihlaltktgkodu, t1.kuladi,t4.ad from ihale_katilimcilar t1, ihale_hareket t2, ihale_sirket t4
    where t1.id_iliski=t2.id_iliski and t1.kuladi=t4.kullaniciadi and t1.ihlkodu=145 and t1.ihlaltktgkodu=135 and t1.aktif=1
    group by t2.teklif, t2.tarih, t1.ihlkodu,t1.ihlaltktgkodu,t1.kuladi,t4.ad
    The result i get is:
    1100YTL 12.02.2008 16:08:16 145 135 KE.ES JKL ***
    1200YTL 12.02.2008 16:03:16 145 135 KE.ES JKL
    1400YTL 12.02.2008 14:35:07 145 135 KEM.ESM ASD ***
    1500 YTL 12.02.2008 14:34:30 145 135 KEM.ESM ASD
    The one i wantto get is the rows of the latest date in each group:
    1100YTL 12.02.2008 16:08:16 145 135 KE.ES JKL [b]***
    1400YTL 12.02.2008 14:35:07 145 135 KEM.ESM ASD ***
    max date -->latest date , most up to date
    Message was edited by:
    user611878
    Message was edited by:
    kem06.ora

  • Group by and decode function

    Can I use a group by on a decode?
    I am using the sql below and get an error message when I
    try to use the group by on a decode.
    select decode(assignment.catcodeid,
    'D', 'SERVICE REQUESTS AND MAINTENANCE',
    'U', 'SERVICE REQUESTS AND MAINTENANCE',
    'P', 'SERVICE REQUESTS AND MAINTENANCE',
    'E', 'SERVICE REQUESTS AND MAINTENANCE',
    'R', 'SERVICE REQUESTS AND MAINTENANCE',
    'T', 'EDUCATION',
    'O', 'OVERHEAD',
    'L', 'UNPAID LEAVE',
    'V', 'VACATION',
    'S', 'SICK PAY',
    'H', 'HOLIDAY',
    'C', 'COMP TIME',
    'UNKNOWN ACTIVITY') "ACTIVITY",
    assignment.catcodeid, assignment.esthrs,
    SUM(ASSIGNMENT.ESTHRS)
    FROM ASSIGNMENT
    GROUP BY ACTIVITY, catcodeid, esthrs
    The error is
    ORA-00904: "ACTIVITY": invalid identifier
    It is understood that Activity is not a field
    on the table.
    But, is there a way that I can group by the result of
    a decode function or what other method/advice I can use to
    group by the result of this.
    Thanks is advance.

    Hello
    You just need to put the decode statement in the group by as well, you can't just use the alias...And if you just group by the catcodeid, you won't be putting all of the SERVICE REQUESTS AND MAINTENANCE rows together. But, because you are selecting the catcodeid aswell as decoding it, that will happen anyway.
    HTH

  • GROUP BY and analytical functions

    Hi all,
    I need your help with grouping my data.
    Below you can see sample of my data (in my case I have view where data is in almost same format).
    with test_data as(
    select '01' as code, 'SM' as abbreviation, 1010 as groupnum, 21 as pieces, 4.13 as volume, 3.186 as avgvolume from dual
    union
    select '01' as code, 'SM' as abbreviation, 2010 as groupnum, 21 as pieces, 0 as volume, 3.186 as avgvolume from dual
    union
    select '01' as code, 'SM' as abbreviation, 3000 as groupnum, 21 as pieces, 55 as volume, 3.186 as avgvolume from dual
    union
    select '01' as code, 'SM' as abbreviation, 3010 as groupnum, 21 as pieces, 7.77 as volume, 3.186 as avgvolume from dual
    union
    select '02' as code, 'SMP' as abbreviation, 1010 as groupnum, 30 as pieces, 2.99 as volume, 0.1 as avgvolume from dual
    union
    select '03' as code, 'SMC' as abbreviation, 1010 as groupnum, 10 as pieces, 4.59 as volume, 0.459 as avgvolume from dual
    union
    select '40' as code, 'DB' as abbreviation, 1010 as groupnum, 21 as pieces, 5.28 as avgvolume, 0.251 as avgvolume from dual
    select
    DECODE (GROUPING (code), 1, 'report total:', code)     as code,
    abbreviation as abbreviation,
    groupnum as pricelistgrp,
    sum(pieces) as pieces,
    sum(volume) as volume,
    sum(avgvolume) as avgvolume
    --sum(sum(distinct pieces)) over (partition by code,groupnum) as piecessum,
    --sum(volume) volume,
    --round(sum(volume) / 82,3) as avgvolume
    from test_data
    group by grouping sets((code,abbreviation,groupnum,pieces,volume,avgvolume),null)
    order by 1,3;Select statement which I have written returns the output below:
    CODE    ABBR    GRPOUP  PIECES   VOLUME  AVGVOL
    01     SM     1010     21     4.13     3.186
    01     SM     2010     21     0     3.186
    01     SM     3000     21     55     3.186
    01     SM     3010     21     7.77     3.186
    02     SMP     1010     30     2.99     0.1
    03     SMC     1010     10     4.59     0.459
    40     DB     1010     21     5.28     0.251
    report total:          145     79.76     13.554Number of pieces and avg volume is same for same codes (01 - pieces = 21, avgvolume = 3.186 etc.)
    What I need is to get output like below:
    CODE    ABBR    GRPOUP  PIECES   VOLUME  AVGVOL
    01     SM     1010     21     4.13     3.186
    01     SM     2010     21     0     3.186
    01     SM     3000     21     55     3.186
    01     SM     3010     21     7.77     3.186
    02     SMP     1010     30     2.99     0.1
    03     SMC     1010     10     4.59     0.459
    40     DB     1010     21     5.28     0.251
    report total:          82     79.76     0.973Where total number of pieces is computed as sum of distinct numbers of pieces for each code -> *82 = 21 + 30 + 10 +21*.
    Total volume is just sum of volumes in each row -> *79.76 = 4.13+0+55+7.77+2.99+4.59+5.28*.
    And Average volume is computed as total volume / total number of pieces -> *0.973 = 79.76 / 82*.
    I was trying to use analytical function (sum() over (partition by)) to get desired output, but without good results.
    Could anyone help me with this issue?
    Thanks in advance!
    Regards,
    Jiri

    Hi, Jiri,
    Jiri N. wrote:
    Hi all,
    I need your help with grouping my data.
    Below you can see sample of my data (in my case I have view where data is in almost same format).I assume the view guarantees that all rows with the same code (or the same code and groupnum) will always have the same pieces and the same avgvolume.
    with test_data as( ...Thanks for posting this; it's very helpful.
    What I need is to get output like below:
    CODE    ABBR    GRPOUP  PIECES   VOLUME  AVGVOL
    01     SM     1010     21     4.13     3.186
    01     SM     2010     21     0     3.186
    01     SM     3000     21     55     3.186
    01     SM     3010     21     7.77     3.186
    02     SMP     1010     30     2.99     0.1
    03     SMC     1010     10     4.59     0.459
    40     DB     1010     21     5.28     0.251
    report total:          82     79.76     0.973
    Except for the last row, you're just displaying data straight from the table (or view).
    It might be easier to get the results you want uisng a UNION. One branch of the UNION would get the"report total" row, and the other branch would get all the rest.
    >
    Where total number of pieces is computed as sum of distinct numbers of pieces for each code -> *82 = 21 + 30 + 10 +21*.It's not just distinct numbers. In this example, two different codes have pieces=21, so the total of distinct pieces is 61 = 21 + 30 + 10.
    >
    Total volume is just sum of volumes in each row -> *79.76 = 4.13+0+55+7.77+2.99+4.59+5.28*.
    And Average volume is computed as total volume / total number of pieces -> *0.973 = 79.76 / 82*.
    I was trying to use analytical function (sum() over (partition by)) to get desired output, but without good results. I would use nested aggregate functions to do that:
    SELECT    code
    ,       abbreviation
    ,       groupnum          AS pricelistgrp
    ,       pieces
    ,       volume
    ,       avgvolume
    FROM      test_data
         UNION ALL
    SELECT        'report total:'     AS code
    ,        NULL                  AS abbreviaion
    ,        NULL               AS pricelistgrp
    ,        SUM (MAX (pieces))     AS pieces
    ,        SUM (SUM (volume))     AS volume
    ,        SUM (SUM (volume))
          / SUM (MAX (pieces))     AS avgvolume
    FROM        test_data
    GROUP BY   code     -- , abbreviation?
    ORDER BY  code
    ,            pricelistgrp
    ;Output:
    CODE          ABB PRICELISTGRP     PIECES  VOLUME  AVGVOLUME
    01            SM          1010         21    4.13      3.186
    01            SM          2010         21    0.00      3.186
    01            SM          3000         21   55.00      3.186
    01            SM          3010         21    7.77      3.186
    02            SMP         1010         30    2.99       .100
    03            SMC         1010         10    4.59       .459
    40            DB          1010         21    5.28       .251
    report total:                          82   79.76       .973It's unclear if you want to GROUP BY just code (like I did above) or by both code and abbreviation.
    Given that this data is coming from a view, it might be simpler and/or more efficient to make separate version of the view, or to replicate most of the view in a query.

  • SQL query using Group by and Aggregate function

    Hi All,
    I need your help in writing an SQL query to achieve the following.
    Scenario:
    I have table with 3 Columns. There are 3 possible values for col3 - Success, Failure & Error.
    Now I need a query which can give me the summary counts for distinct values of col3 for each GROUP BY of col1 and col2 values. When there are no values for col3 then it should return ZERO count.
    Example Data:
    Col1 Col2 Col3
    abc 01 success
    abc 02 success
    abc 01 success
    abc 01 Failure
    abc 01 Error
    abc 02 Failure
    abc 03 Error
    xyz 07 Failure
    Required Output:
    c1 c2 s_cnt F_cnt E_cnt (Heading)
    abc 01 2 1 1
    abc 02 1 1 0
    abc 03 0 0 1
    xyz 07 0 1 0
    s_cnt = Success count; F_cnt = Failure count; E_cnt = Error count
    Please note that the output should have 5 columns with col1, col2, group by (col1,col2)count(success), group by (col1,col2)count(failure), group by (col1,col2)count(error)
    and where ever there are NO ROWS then it should return ZERO.
    Thanks in advance.
    Regards,
    Shiva

    Hi,
    user13015050 wrote:
    Thanks TTT. Unfortunately I cannot use this solution because I have huge data for this.T's solution is basically the same as mine. The first 23 lines just simulates your table. Since you actually have a table, you would start with T's line 24:
    SELECT col1 c1, col2 c2, SUM(decode(col3, 'success', 1, 0)) s_cnt, ...
    user13015050 wrote:Thanks a lot Frank. It helped me out. I just did some changes to this as below and have no issues.
    SELECT     col1
    ,     col2
    ,     COUNT ( CASE
              WHEN col3 = 'SUCCESS'
              THEN 1
              END
         )          AS s_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'FAILED'
              THEN 1
              END
         )          AS f_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'ERROR'
              THEN 1
              END
         )          AS e_cnt
    FROM     t1
    WHERE c2 in ('PURCHASE','REFUND')
    and c4 between to_date('20091031000000','YYYYMMDDHH24MISS') AND to_date('20100131235959','YYYYMMDDHH24MISS')
    GROUP BY c1, c2
    ORDER BY c1, c2;
    Please let me know if you see any issues in this query.It's very hard to read.
    This site normally compresses spaces. Whenever you post formatted text (such as queries or results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Also, post exactly what you're using.  The code above is SELECTing col1 and col2, but there's no mention of either in the GROUP BY clause, so I don't believe it's really what you're using.
    Other than that, I don't see anything wrong or suspicious in the query.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem with group by and sum function

    In one of the report I'm using grioup by clause on one column. However when I use this function the sum function on other column is not working.
    Any idea how we can resolve this?

    Hi Tintin,
    Follow the below steps:
    1) On the order number column formula, use the max function.
    2) Duplicate the revenue column in the RPD, set the aggregation to sum and level to transaction. This will give you the sum of all the orders in a particular trasaction, where as in report you will see only the max account number.
    Assign points if helpful.
    Thanks,
    -Amith.

  • No entries in Define conversion group and external function module setting.

    Hi all,
    After active bussiness function SAP Oil & Gas, my system have a problem in SPRO.
    SPRO --> IMG --> Industry solution Oil & Gas (Downstream) --> HPM --> QCI configuration --> Define conversion group and external function module setting.
    Problem appear: Has no entries in there!
    Please, help me! Thank you so much!
    Tks & best regards,
    DatHT

    Dat,
    There are few entries normally delivered by SAP and which are good for a regular implementation. It is possible that those are not copied over from the reference client. Second option is to check the BC set (if) available for this activity and pull those in. Check the SAP reference client first, most likely that has entries which you can copy over to your regular client.
    Regards,

  • Account Group and Partner Function

    Hello All,
    Can any one tell me how can i assign particular Account group to all partner functions.
    Thanks
    Sundu

    Hi Sundar,
    Its very simple.
    Go to IMG - SPRO - SD - BASIC FUNCTIONS - PARTNER DETERMINATION - SET UP PARTNER DETERMINATION - SET UP PARTNER DETERMINATION FOR CUSTOMER MASTER
    Now select Account Groups - Function Assignment in the left hand side column.
    Now based on the account group that you use while creating customers through either XD01 or BP transaction, assign the relevant partner functions against your account group.
    This should help you solve your query.
    Reward points if helpful.
    Regards
    Ravi

  • Autogenerate Group By, only on demand?

    Hi,
    I find SQL Developer's "Autogenerate Group By" function very useful. But it can be quite annoying as well, especially when I'm editing an existing query. It would be great if I could create my own code up to a point, and then invoke the "autogenerate" function when I'm ready.
    I saw this blog post by Jeff Smith: http://www.thatjeffsmith.com/archive/2012/07/auto-generate-group-by-clauses-with-oracle-sql-developer/. It seems to indicate that this is in fact possible, quote: "I disable the automatic bits and just call it on demand with ctrl+spacebar". Ctrl-spacebar doesn't seem to do anything with "auto-group by" for me. Am I missing something?
    TIA!

    This is one of the changes coming in SQL Developer 4.0, with the "Semantic Advisor" feature (the early adopter release is out if you want to play with it).
    See Jeff Smith's blog post for more info.
    http://www.thatjeffsmith.com/archive/2013/07/semantic-analysis-info-tips-in-oracle-sql-developer-4-0/

  • GUI_DOWNLOAD and UPLOAD Function Modules?

    Hi All,
    What exactly done by GUI_DOWNLOAD and UPLOAD Function Modules?
    Akshitha.

    What you exactly want know?
    Here is the Sap documentation for both FM:
    FU GUI_UPLOAD
    Short Text
    Upload for Data Provider
    Functionality
    The module loads a file from the PC to the server. Data can be transferred binarily or as text. Numbers and date fields can be interpreted according to the user settings.
    Example
    Binary upload: No conversion or interpretation
                begin of itab,
                      raw(255) type x,
                end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype =  'BIN'
                  filename = 'C:\DOWNLOAD.BIN'
               tables
                 data_tab = itab.
    Text upload
               begin of itab,
                     text(255) type c,
               end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype = 'ASC'
                  filename = 'C:\DOWNLOAD.TXT'
               tables
                 data_tab = itab.
    Parameters
    FILENAME
    FILETYPE
    HAS_FIELD_SEPARATOR
    HEADER_LENGTH
    READ_BY_LINE
    DAT_MODE
    CODEPAGE
    IGNORE_CERR
    REPLACEMENT
    CHECK_BOM
    VIRUS_SCAN_PROFILE
    NO_AUTH_CHECK
    FILELENGTH
    HEADER
    DATA_TAB
    Exceptions
    FILE_OPEN_ERROR
    FILE_READ_ERROR
    NO_BATCH
    GUI_REFUSE_FILETRANSFER
    INVALID_TYPE
    NO_AUTHORITY
    UNKNOWN_ERROR
    BAD_DATA_FORMAT
    HEADER_NOT_ALLOWED
    SEPARATOR_NOT_ALLOWED
    HEADER_TOO_LONG
    UNKNOWN_DP_ERROR
    ACCESS_DENIED
    DP_OUT_OF_MEMORY
    DISK_FULL
    DP_TIMEOUT
    Function Group
    SFES
    FU GUI_DOWNLOAD
    Short Text
    Download an Internal Table to the PC
    Functionality
    Data transfer of an internal table form the server to a file on the PC. The Gui_Download module replaces the obsolete modules Ws_Download and Download. The file dialog of the download module is available in the class Cl_Gui_Frontend_Services.
    Further information
    TYPE-POOLS: ABAP.
    Binary download table
    DATA: BEGIN OF line_bin,
             data(1024) TYPE X,
          END OF line_bin.
    DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
    Ascii download table
    DATA: BEGIN OF line_asc,
             text(1024) TYPE C,
          END OF line_asc.
    DATA: data_tab_asc LIKE STANDARD TABLE OF line_asc.
    DAT download table
    DATA: BEGIN OF line_dat,
             Packed   TYPE P,
             Text(10) TYPE C,
             Number   TYPE I,
             Date     TYPE D,
             Time     TYPE T,
             Float    TYPE F,
             Hex(3)   TYPE X,
             String   TYPE String,
          END OF line_dat.
    DATA: data_tab_dat LIKE STANDARD TABLE OF line_dat.
    Get filename
    DATA: fullpath      TYPE String,
          filename      TYPE String,
          path          TYPE String,
          user_action   TYPE I,
          encoding      TYPE ABAP_ENCODING.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
       EXPORTING
         WINDOW_TITLE         = 'Gui_Download Demo'
         WITH_ENCODING        = 'X'
         INITIAL_DIRECTORY    = 'C:\'
      CHANGING
         FILENAME             = filename
         PATH                 = path
         FULLPATH             = fullpath
         USER_ACTION          = user_action
         FILE_ENCODING        = encoding
      EXCEPTIONS
         CNTL_ERROR           = 1
         ERROR_NO_GUI         = 2
         NOT_SUPPORTED_BY_GUI = 3
         others               = 4.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    IF user_action <> CL_GUI_FRONTEND_SERVICES=>ACTION_OK.
      EXIT.
    ENDIF.
    Download variables
    DATA: length TYPE I.
    Binary download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'BIN'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_bin
       EXCEPTIONS
         FILE_WRITE_ERROR                = 1
         NO_BATCH                         = 2
         GUI_REFUSE_FILETRANSFER         = 3
         INVALID_TYPE                     = 4
         NO_AUTHORITY                     = 5
         UNKNOWN_ERROR                   = 6
         HEADER_NOT_ALLOWED              = 7
         SEPARATOR_NOT_ALLOWED           = 8
         FILESIZE_NOT_ALLOWED            = 9
         HEADER_TOO_LONG                 = 10
         DP_ERROR_CREATE                 = 11
         DP_ERROR_SEND                   = 12
         DP_ERROR_WRITE                  = 13
         UNKNOWN_DP_ERROR                = 14
         ACCESS_DENIED                   = 15
         DP_OUT_OF_MEMORY                = 16
         DISK_FULL                        = 17
         DP_TIMEOUT                       = 18
         FILE_NOT_FOUND                  = 19
         DATAPROVIDER_EXCEPTION          = 20
         CONTROL_FLUSH_ERROR             = 21
         OTHERS                           = 22.
    Ascii download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'ASC'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_asc
       EXCEPTIONS
         FILE_WRITE_ERROR                = 1
         NO_BATCH                         = 2
         GUI_REFUSE_FILETRANSFER         = 3
         INVALID_TYPE                     = 4
         NO_AUTHORITY                     = 5
         UNKNOWN_ERROR                   = 6
         HEADER_NOT_ALLOWED              = 7
         SEPARATOR_NOT_ALLOWED           = 8
         FILESIZE_NOT_ALLOWED            = 9
         HEADER_TOO_LONG                 = 10
         DP_ERROR_CREATE                 = 11
         DP_ERROR_SEND                   = 12
         DP_ERROR_WRITE                  = 13
         UNKNOWN_DP_ERROR                = 14
         ACCESS_DENIED                   = 15
         DP_OUT_OF_MEMORY                = 16
         DISK_FULL                        = 17
         DP_TIMEOUT                       = 18
         FILE_NOT_FOUND                  = 19
         DATAPROVIDER_EXCEPTION          = 20
         CONTROL_FLUSH_ERROR             = 21
         OTHERS                           = 22.
    DAT download
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                         = fullpath
           FILETYPE                         = 'DAT'
        IMPORTING
          FILELENGTH                       = length
        TABLES
          DATA_TAB                         = data_tab_dat
       EXCEPTIONS
         FILE_WRITE_ERROR                = 1
         NO_BATCH                         = 2
         GUI_REFUSE_FILETRANSFER         = 3
         INVALID_TYPE                     = 4
         NO_AUTHORITY                     = 5
         UNKNOWN_ERROR                   = 6
         HEADER_NOT_ALLOWED              = 7
         SEPARATOR_NOT_ALLOWED           = 8
         FILESIZE_NOT_ALLOWED            = 9
         HEADER_TOO_LONG                 = 10
         DP_ERROR_CREATE                 = 11
         DP_ERROR_SEND                   = 12
         DP_ERROR_WRITE                  = 13
         UNKNOWN_DP_ERROR                = 14
         ACCESS_DENIED                   = 15
         DP_OUT_OF_MEMORY                = 16
         DISK_FULL                        = 17
         DP_TIMEOUT                       = 18
         FILE_NOT_FOUND                  = 19
         DATAPROVIDER_EXCEPTION          = 20
         CONTROL_FLUSH_ERROR             = 21
         OTHERS                           = 22.
    Parameters
    BIN_FILESIZE
    FILENAME
    FILETYPE
    APPEND
    WRITE_FIELD_SEPARATOR
    HEADER
    TRUNC_TRAILING_BLANKS
    WRITE_LF
    COL_SELECT
    COL_SELECT_MASK
    DAT_MODE
    CONFIRM_OVERWRITE
    NO_AUTH_CHECK
    CODEPAGE
    IGNORE_CERR
    REPLACEMENT
    WRITE_BOM
    TRUNC_TRAILING_BLANKS_EOL
    WK1_N_FORMAT
    WK1_N_SIZE
    WK1_T_FORMAT
    WK1_T_SIZE
    WRITE_EOL
    FILELENGTH
    DATA_TAB
    FIELDNAMES
    Exceptions
    FILE_WRITE_ERROR
    NO_BATCH
    GUI_REFUSE_FILETRANSFER
    INVALID_TYPE
    NO_AUTHORITY
    UNKNOWN_ERROR
    HEADER_NOT_ALLOWED
    SEPARATOR_NOT_ALLOWED
    FILESIZE_NOT_ALLOWED
    HEADER_TOO_LONG
    DP_ERROR_CREATE
    DP_ERROR_SEND
    DP_ERROR_WRITE
    UNKNOWN_DP_ERROR
    ACCESS_DENIED
    DP_OUT_OF_MEMORY
    DISK_FULL
    DP_TIMEOUT
    FILE_NOT_FOUND
    DATAPROVIDER_EXCEPTION
    CONTROL_FLUSH_ERROR
    Function Group
    SFES

  • Any difference between distinct and aggregate function in sql query cost???

    Hi,
    I have executed many sql stmts patterns- such as:
    a) using a single table
    b) using two tables, using simple joins or outer joins
    but i have not noticed any difference in sql stmts in cost and in execution plan....
    Anyway, my colleague insists on that using aggregate function is less costly compared to
    distinct....(something i have not confirmed, that's why i beleive that they are exactly the same...)
    For the above reffered 1st sql pattern.. we could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_typeHave you found any difference between the two ever...????
    Note: I use Ora DB 10g v2.
    Thank you,
    Sim

    distinct and aggregate function are for different uses and may give same result but if u r using aggregate function to get distinct records, it will be expensive...
    ex
    select distinct deptno from scott.dept;
    Statistics
    0 recursive calls
    0 db block gets
    2 consistent gets
    0 physical reads
    0 redo size
    584 bytes sent via SQL*Net to client
    488 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    4 rows processed
    select deptno from scott.emp group by deptno;
    Statistics
    307 recursive calls
    0 db block gets
    60 consistent gets
    6 physical reads
    0 redo size
    576 bytes sent via SQL*Net to client
    488 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    6 sorts (memory)
    0 sorts (disk)
    3 rows processed
    Nimish Garg
    Software Developer
    *(Oracle & ASP.NET)*
    Indiamart Intermesh Limited, Noida
    To Get Free Oracle & ASP.NET Code Snippets
    Follow: http://nimishgarg.blogspot.com

  • COUNT() and SUM() function it not working in XDO file.

    Hi ,
    I am getting one error. Count and sum function not working proper.
    For example :
    Department 10 have 3 employee and total salary is 8750. But my report returning total employee 1 and total salary 5000
    10
    Ename Sal
    KING 5000
    CLARK 2450
    MILLER 1300
    ==================
    total employee : 1
    total salary : 5000
    Kindly help me solve this problem.
    <dataTemplate name="TEXT">
    <properties>
    <property value="upper" name="xml_tag_case" />
    </properties>
    <lexicals>
    </lexicals>
    <dataQuery>
    <sqlstatement name="Q_TEMP">
    <![CDATA[SELECT DEPTNO,DNAME,LOC FROM DEPT]]>
    </sqlstatement>
    <sqlstatement name="Q_TEMP1">
    <![CDATA[SELECT ENAME,HIREDATE,SAL FROM EMP WHERE DEPTNO = :DEPTNO]]>
    </sqlstatement>
    </dataQuery>
    <datastructure>
    <GROUP name="G_1" source="Q_TEMP">
    <element value="DEPTNO" name="DEPTNO" />
    <element value="DNAME" name="DNAME" />
    <element value="LOC" name="LOC" />
    <GROUP name="G_2" source="Q_TEMP1">
    <element value="ENAME" name="ENAME" />
    <element value="SAL" name="SAL" />
    <element value="G_2.ENAME" name="TOTL_DETAILS" dataType="number" function="COUNT()" />
    <element value="G_2.SAL" name="TOTL_SAL" function="SUM()"/>
    </GROUP>
    </GROUP>
    </datastructure>
    </dataTemplate>
    Thanks
    Yudhi

    Please have the data structure as below:
    <datastructure>
    <GROUP name="G_1" source="Q_TEMP">
    <element value="DEPTNO" name="DEPTNO" />
    <element value="DNAME" name="DNAME" />
    <element value="LOC" name="LOC" />
    <GROUP name="G_2" source="Q_TEMP1">
    <element value="ENAME" name="ENAME" />
    <element value="SAL" name="SAL" />
    *</GROUP>*
    *<element value="G_2.ENAME" name="TOTL_DETAILS" dataType="number" function="COUNT()" />*
    *<element value="G_2.SAL" name="TOTL_SAL" function="SUM()"/>*
    *</GROUP>*
    </datastructure>
    Aggregate functions to be placed at the level you require it. Here you need at G_1, so place it there.

  • Group Items and Change Scale Using CS3 VBScript

    How do you select items in a textframe (text and/or graphic and/or rectangle), then group them and then set the group to a horizontal & vertical scale value?
    Thanks,
    Archie

    What would be the best way to do that? As an example I would have 8 textframes threaded together (each frame is a stamp, this script is for reducing the image to print the label that goes on the top of the stamp). Some frames could only be text, some only a graphic, some both, some blank. Below is an example of what have so far. This works if the frame is only text.
    Thanks,
    Archie
    Rem SCALE ITEMS FUNCTION
    Rem --------------------
    Function myScaleItems (myLabelDocument)
    For I = 4 to 11
    myLabelDocument.textframes.item(I).locked = False
    myLabelDocument.textframes.item(I).HorizontalScale = cInt(myLabelPercent)
    myLabelDocument.textframes.item(I).VerticalScale = cInt(myLabelPercent)
    Next
    End Function

  • Group by and partioned by

    Hi
    Can any one explain difference between group by and partioned by
    Regards,

    Hi,
    Group functions operate on sets of rows to give one result per group.
    group by functions:
    AVG
    COUNT
    MAX
    MIN
    STDDEV
    SUM
    VARIANCE
    each group defined with GROUP BY clause in a SELECT statement is called
    a partition. A query result set may have just one partition holding all the rows, a few large
    partitions, or many small partitions holding just a few rows each.
    In such cases analytical functions are used for each row in each parition
    regards
    nic

  • How to group data and assign cell names using Excel templates

    Hi all,
    reading the article "Real Excel Templates 1.5" on the Tim Dexter's Blog, I found that I need hierarchical data for Excel templates. So only in this way I can group my data.
    My hierarchy is composed by 3 levels:
    lev 1 DESTINATION: is the higher level that groups SERVICES and COUNTRY
    lev 2 SERVICES: is the level that groups the countries
    lev 3 COUNTRY: is the lowest level with the COUNTRY, CALLS and CALLS_MINUTES details
    An example of my hierarchy is this:
    lev 1 INTERNATIONAL
    lev 2 INTERNATIONAL FIXED
    lev 3 Albania 90 438,15
    lev 3 Armenia 1 16,95
    lev 2 INTERNATIONAL MOBILE
    lev 3 Albania Mobile 161 603,35
    lev 3 Australia Mobile 6 34,38
    lev 1 NATIONAL
    lev 2 HELLAS LOCAL
    lev 3 Hellas Local 186,369 707940,6
    lev 2 HELLAS MOBILE
    lev 3 Hellas Mobile Cosmote 31,33 43856,97
    lev 3 Hellas Mobile Q-Telecom 2,398 4343,78
    lev 2 HELLAS NATIONAL
    lev 3 Hellas Long Distance 649 1499,55
    lev 1 INTERNET
    lev 2 INTERNET CALLS
    lev 3 Cosmoline @Free 79 2871,3
    So, my data template is the following (with exactly the hierarchy I want for my data):
    <dataTemplate name="emp" description="destinations" dataSourceRef="GINO_DB">
         <dataQuery>
              <sqlStatement name="Q1">
                   <![CDATA[SELECT 1 TOTAL_CALLS, 2 TOTAL_CALLS_MIN from dual ]]>
              </sqlStatement>
              <sqlStatement name="Q2">
                   <![CDATA[SELECT dest.ID_DESTINATION, dest.DESC_DEST from ale.AAA_DESTINATION dest order by dest.ID_DESTINATION ]]>
              </sqlStatement>
              <sqlStatement name="Q3">
                   <![CDATA[SELECT ser.ID_SERVICE,
    ser.ID_DEST,
    ser.DESC_SERVICE,
    count.ID_COUNTRY,
    count.ID_SERV,
    count.COUNTRY,
    count.CALLS,
    count.CALLS_MIN
    from ale.AAA_SERVICE ser, ale.AAA_COUNTRY count
    where ser.ID_SERVICE= count.ID_SERV
    and ID_DEST = :ID_DESTINATION
    order by ser.ID_SERVICE ]]>
              </sqlStatement>
         </dataQuery>
         <dataStructure>
              <group name="G_TOT" source="Q1">
                   <element name="TOTAL_CALLS" value="G_COUNTRY.CALLS" function="SUM()"/>
                   <element name="TOTAL_CALLS_MIN" value="G_COUNTRY.CALLS_MIN" function="SUM()"/>
                   <group name="G_DEST" source="Q2">
                        <element name="DESC_DEST" value="DESC_DEST"/>
                        <element name="DEST_CALLS_SUBTOTAL" value="G_COUNTRY.CALLS" function="SUM()"/>
                        <element name="DEST_CALLS_MIN_SUBTOTAL" value="G_COUNTRY.CALLS_MIN" function="SUM()"/>
                        <group name="G_SERV" source="Q3">
                             <element name="DESC_SERVICE" value="DESC_SERVICE"/>
                             <element name="SERV_CALLS_SUBTOTAL" value="G_COUNTRY.CALLS" function="SUM()"/>
                             <element name="SERV_CALLS_MIN_SUBTOTAL" value="G_COUNTRY.CALLS_MIN" function="SUM()"/>
                             <group name="G_COUNTRY" source="Q3">
                                  <element name="COUNTRY" value="COUNTRY"/>
                                  <element name="CALLS" value="CALLS"/>
                                  <element name="CALLS_MIN" value="CALLS_MIN"/>
                             </group>
                        </group>
                   </group>
              </group>
         </dataStructure>
    </dataTemplate>
    Not considering the CALLS and CALLS_MIN details (I focused only on the COUNTRY which is as the same level), with this data template, making tests on my excel template, I noticed that I can group ONLY two nested levels using the format XDO_GROUP_?group_name?
    XDO_GROUP_?G_DEST?
    XDO_GROUP_?G_SERV?
    or
    XDO_GROUP_?G_DEST?
    XDO_GROUP_?G_COUNTRY?
    or
    XDO_GROUP_?G_SERV?
    XDO_GROUP_?G_COUNTRY
    If I try to group all the three level together in this order
    XDO_GROUP_?G_DEST?
    XDO_GROUP_?G_SERV?
    XDO_GROUP_?G_COUNTRY
    I don't have the output I would like to have.....
    Practically, in my excel I have 3 rows with the following labels
    DESTINATION (called XDO_?DESC_DEST? - =Sheet1!$A$3
    SERVICE (called XDO_?DESC_SERVICE? - =Sheet1!$A$4
    COUNTRY (called XDO_?COUNTRY? - =Sheet1!$A$5)
    where
    XDO_GROUP_?G_DEST? (=Sheet1!$A$3:$B$5)
    XDO_GROUP_?G_SERV? (=Sheet1!$A$4:$B$5)
    XDO_GROUP_?G_COUNTRY     (=Sheet1!$A$5:$B$5)
    I noticed that if I don't use the last one (XDO_GROUP_?G_COUNTRY), my output is correct even if I don't have more than one country for each service....As soon as I put XDO_GROUP_?G_COUNTRY....I loose all the 2nd level and the most of times the 3rd level too....
    So...I think that the problem is how I choose the excel cells when I assign the XDO_GROUP_?group_name?
    Anybody had made some tests, or can help me ???? I'm becoming crazy.....
    Any help will be appreciated
    Thanks in advance
    Alex

    But how can I use tags XDO_GROUP_?? to group data correctly using hierarchial xml, I don't want to use flat XML.
    Yep, I using Template Builder in Excel to run reports localy, and output is wrong
    It's seems that groups couldn't define the level of nesting, I think...
    How can I write it in XDO_METADATA sheet?
    Though I have hierarchial XML and groups should define nesting level correctly.
    I have no clue.....

Maybe you are looking for