Grouping of Rows in a Query

Hi Experts,
I have a requirement as follows:
100 User Group
    A100 Users xxxx   100  ..... 50
    A101 Users yyyy   100   ...  60
    Total                                110
50 Users Group
     A50 Users zfdcfs    50 .....  25
     A50 Users adcga    50 ....   15
   Total                                   45
20 Users Group
     B20 Users hadcf     20
     B20 Users sghdf     20
My problem is I have several Hierarchies for Users Group, but I can use none as they are grouped differently. Secondly I don't even have the indicator or anything in the InfoProvider to identify them as 100, 50, 20. My first question is - is there any way to create a different grouping at the reporting level and also generate total for each group ? My Second question is - I need to show 100, 50,20 in the report which is noway avaialble in the infoprovider, is it possible to create any contanst CKF or RKF, which I can use for display and also for calculation?
Thanks
Paromita
Message was edited by:
        Paromita Das

Can you create your own Hierarchy and group the users as per your application needs?
If there is a good reason for not creating a new hierarchy then you can look at alternatives.
Good luck, BB

Similar Messages

  • Grouping rows from a query

    Hi everyone!
    I want to know if it's posible to group the rows from a query into a unique row. Example:
    SELECT Field_1 FROM Table_1
    Returns the following fileds:
    Field_1
    A
    B
    C
    D
    I would want to modify my query so that the result obtained would be a single row containing all the others. In the previous example the result would be "ABCD".
    Thanks in advance. Best regards,

    -- For anyone who wants to test this,
    -- just copy this entire post as is,
    -- save it to a .sql file, then start that file.
    -- Before doing this,
    -- make sure that you don't already have
    -- a table named table_1 that would be dropped
    -- or a .sql file named query.sql that would be overwritten.
    -- If you do, then change the names below to avoid any conflicts.
    -- In order to understand what the code is doing,
    -- please read all of the comments included in this file,
    -- as not everything is displayed when you run it.
    -- I have gone into great detail with this
    -- because I have posted similar things before
    -- and a lot of people have total missed the fact
    -- that it is not a static query,
    -- that the results are dependent upon the number of rows,
    -- and that it works for any number of rows,
    -- even when the number of rows is unknonwn.
    -- test data:
    DROP TABLE table_1
    CREATE TABLE table_1
      (field_1 VARCHAR2 (1))
    INSERT INTO table_1 (field_1)
    VALUES ('A')
    INSERT INTO table_1 (field_1)
    VALUES ('B')
    INSERT INTO table_1 (field_1)
    VALUES ('C')
    INSERT INTO table_1 (field_1)
    VALUES ('D')
    COMMIT
    SELECT * FROM table_1
    -- Running the code below will create and start
    -- a file named query.sql which will contain the query below,
    -- which will produce the results below that:
    -- query that will be created:
    -- SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))                                      
    -- ||MAX(DECODE(ROWNUM,2,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,3,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,4,field_1,NULL))                                           
    -- FROM table_1 GROUP BY NULL;                                                    
    -- results that will be produced:
    -- ABCD
    -- Notice that in this example,
    -- there are only four values concatenated
    -- because there are only four rows in the table. 
    -- If there were more rows, it would concatenate more values. 
    -- The number of concatenated values
    -- is dependent upon the number of rows.
    -- The following dynamic sql uses a single query,
    -- which produces and executes a single query,
    -- whose number of concatenated values is dependent
    -- upon the number of rows in the table.
    -- Because the echo is set off in the first line,
    -- you won't see this code when you run it,
    -- just the query that it creates.
    SET     ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF
    SPOOL   query.sql
    -- This is the start of the single query:
    SELECT  text
    FROM    (SELECT 1                                             AS orderby,
                    'SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))'   AS text
             FROM   DUAL
             UNION
             -- This section is the part that dynamically creates
             -- one additional concatenated value
             -- for each additional row after the first row.
             -- This is just a subquery within the single query.
             SELECT rn                                            AS orderby,
                    '||MAX(DECODE(ROWNUM,'||rn||',field_1,NULL))' AS text
             FROM   (SELECT ROWNUM rn
                     FROM   table_1)
             WHERE  rn > 1
             UNION
             SELECT COUNT (*) + 1                                  AS orderby,
                    'FROM table_1 GROUP BY NULL;'                  AS text
             FROM   table_1)
    ORDER BY orderby;
    -- This is the end of the single query.
    SPOOL    OFF
    START    query
    SET      ECHO ON
    -- If you want to see the file containing
    -- the single query that was created, then just:
    -- SQL> EDIT query.sql

  • How to Group Few Rows into One Rows In Query

    Dear All,
    I've use the "Group By" syntax in my query, but when the result display, it still show few rows instead of one row.
    Current Results
    item         Jan       Feb        Mar
    A              10          0           20
    A              10          0            0
    A               0           5            0
    B               0           0           10
    Desire Result
    item        Jan         Feb         Mar
    A             20           5           20
    B             0             0           10
    My query is:
    /*select from [dbo].[oinv] T0 */
    declare @customer varchar (200)
    /* where */
    set @customer = /* T0.Cardname */ '[%A]'
    /*select from [dbo].[inv1] T1 */
    declare @fromdate as datetime
    /* where */
    set @fromdate = /* T1.DOCDATE */ '[%1]'
    /*select from [dbo].[inv1] T2 */
    declare @tilldate as datetime
    /* where */
    set @tilldate = /* T1.DOCDATE */ '[%2]'
    SELECT inv1.ITEMCODE, oitm.itemname,
    CASE WHEN MONTH(INV1.DOCDATE) = 1 THEN SUM(QUANTITY) ELSE NULL END AS 'JAN',
    CASE WHEN MONTH(INV1.DOCDATE) = 2 THEN SUM(QUANTITY) ELSE NULL END AS 'FEB',
    CASE WHEN MONTH(INV1.DOCDATE) = 3 THEN SUM(QUANTITY) ELSE NULL END AS 'MAR',
    CASE WHEN MONTH(INV1.DOCDATE) = 4 THEN SUM(QUANTITY) ELSE NULL END AS 'APR',
    CASE WHEN MONTH(INV1.DOCDATE) = 5 THEN SUM(QUANTITY) ELSE NULL END AS 'MAY',
    CASE WHEN MONTH(INV1.DOCDATE) = 6 THEN SUM(QUANTITY) ELSE NULL END AS 'JUN',
    CASE WHEN MONTH(INV1.DOCDATE) = 7 THEN SUM(QUANTITY) ELSE NULL END AS 'JUL',
    CASE WHEN MONTH(INV1.DOCDATE) = 8 THEN SUM(QUANTITY) ELSE NULL END AS 'AUG',
    CASE WHEN MONTH(INV1.DOCDATE) = 9 THEN SUM(QUANTITY) ELSE NULL END AS 'SEPT',
    CASE WHEN MONTH(INV1.DOCDATE) = 10 THEN SUM(QUANTITY) ELSE NULL END AS 'OCT',
    CASE WHEN MONTH(INV1.DOCDATE) = 11 THEN SUM(QUANTITY) ELSE NULL END AS 'NOV',
    CASE WHEN MONTH(INV1.DOCDATE) = 12 THEN SUM(QUANTITY) ELSE NULL END AS 'DEC'
    FROM OINV inner join inv1 on oinv.DocEntry = inv1.DocEntry INNER JOIN OITM on inv1.itemcode = oitm.itemcode
    WHERE oinv.cardname =@customer AND inv1.DOCDATE >=@fromdate AND inv1.DOCDATE <=@tilldate
    GROUP BY inv1.ITEMCODE, oitm.itemname, inv1.docdate
    I've tried to write in "Select Syntax" too, but still get the same result. I'm really have no idea what's wrong with my query. Thanks for all your help!
    Cheers,
    Serene

    Hi Serene,
    in last query I forgot in subquery condition for customer (the sum was for all customers).
    Try this:
    SELECT distinct inv1.ITEMCODE, oitm.itemname,
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock) where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 1 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JAN',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 2 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'FEB',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where  xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 3 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'MAR',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 4 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'APR',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 5 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'MAY',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 6 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JUN',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 7 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'JUL',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 8 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'AUG',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 9 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'SEP',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 10 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'OCT',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and  inv1.itemcode = x.itemcode and month(x.docdate ) = 11 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'NOV',
    (select coalesce(sum(x.quantity),0) from inv1 x with(nolock), oinv xx with(nolock)  where xx.docentry = x.docentry and xx.cardname = @customer and inv1.itemcode = x.itemcode and month(x.docdate ) = 12 and x.DOCDATE >=@fromdate AND x.DOCDATE <=@tilldate) as 'DEC'
    FROM OINV
    inner join inv1 on oinv.DocEntry = inv1.DocEntry
    INNER JOIN OITM on inv1.itemcode = oitm.itemcode
    WHERE oinv.cardname =@customer and quantity > 0
    AND inv1.DOCDATE >=@fromdate AND inv1.DOCDATE <=@tilldate

  • Single row from this query without create a group by

    Can I have a single row from this query without create a group by on tipo (TIPO can have only 2 value (A,D)
    SELECT
    CASE TIPO
    WHEN 'D' THEN SUM(IMPORTO) ELSE 0 END DIMPORTO,
    CASE TIPO
    WHEN 'A' THEN SUM(IMPORTO) ELSE 0 END AIMPORTO
    FROM MGIORNALE
    WHERE K_CONTO = '100001' --CONTO
    AND DECODE(T_MOVIM,'MRAP',TO_DATE('31/12/'||to_char(a_competenza),'DD/MM/YYYY'),DATA_RG)
    -- BETWEEN DATAA AND DATAB
    BETWEEN '01/01/2006' AND '31/12/2006'
    --GROUP BY TIPO
    --AND TIPO = COL_conto
    Thanks in advance

    Is like this?
    sum (CASE TIPO
    WHEN 'D' THEN IMPORTO ELSE 0 END) DIMPORTO,

  • Picking a Max value row out of a group of rows.

    Hi,
    I'm using Oracle 10.2.0.4.0
    For some reason I can't come up with a way to pick out a simple row that contains the max date value out of a group of sub group of rows. The following rows are one group of the result of a complex view ordered by ACCOUNT_NUMBER. I'm just showing the first group for Demo Purposes.
    CUSTOMER_NAME          ACCOUNT_NUMBER     BOOKED_DATES     OUTSTANDING_APPROVALS     BOOKED_NOT_BILLED         SALES
    ABC company, LLC     114943          05/22/2008                   11:17:05           100,072.43          100,072.43
    ABC company, LLC     114943          06/30/2008                   15:12:29           129,956.00          129,956.00
    ABC company, LLC     114943          07/30/2008                   15:57:16           10,957.00          10,957.00This is just the first of many groups in this view. I just need a simple way to select the row with the max BOOKED_DATES. I've tried everything I could think of but the other two rows are not going away. MAX(BOOKED_DATES) is not working in the HAVING section. I just want my out output to be the rows out of each group with the most recent BOOKED_DATES.
    Therefor , my output would be
    CUSTOMER_NAME          ACCOUNT_NUMBER     BOOKED_DATES     OUTSTANDING_APPROVALS     BOOKED_NOT_BILLED         SALES
    ABC company, LLC     114943          07/30/2008                   15:57:16           10,957.00          10,957.00for ACCOUNT_NUMBER 114943. For the truly curious, the query is below. I'm sure the solution is simple but not to me this day. Maybe it's a Monday thing.
    Thanks in Advance.
    select  distinct
    party.party_name CUSTOMER_NAME, --"Customer Name"
    cust_acct.account_number ACCOUNT_NUMBER,--"Account Number"
    max(h.BOOKED_DATE)  BOOKED_DATES,-- "Booked Dates",
    osa.OUTSTANDING_SALE_AMT    OUTSTANDING_APPROVALS,--"Outstanding Approvals",
    ola2.BOOKED_NOT_BILLED                                     BOOKED_NOT_BILLED,
    --ola.line_id,
    --h.header_id,
    sum(nvl(ola.ORDERED_QUANTITY,0) * nvl(ola.UNIT_LIST_PRICE,0))   SALES,
    CASE
       WHEN
       invoiced_amt_info.TERMS = 'Current'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL
    END  "CURRENT_IA",--"Current",
    CASE
       WHEN
       invoiced_amt_info.TERMS = 'Current'
        THEN invoiced_amt_info.CURRENT_TAX 
       ELSE NULL
    END CURRENT_TAX,--"Current Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '1-30 days'
        THEN invoiced_amt_info.CURRENT_INV 
       ELSE NULL
    END     LT_30_DAYS,--  "1-30 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '1-30 days'
        THEN invoiced_amt_info.CURRENT_TAX  
       ELSE NULL
    END     LT_30_DAYS_TAX,-- "1-30 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '31-60 days'
        THEN invoiced_amt_info.CURRENT_INV 
       ELSE NULL 
    END     LT_60_DAYS,-- "1-60 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '31-60 days'
        THEN invoiced_amt_info.CURRENT_TAX
       ELSE NULL
    END     LT_60_DAYS_TAX,--"1-60 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '61-90 days'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL
    END     LT_90_DAYS,-- "1-90 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '61-90 days'
        THEN invoiced_amt_info.CURRENT_TAX 
       ELSE NULL
    END     LT_90_DAYS_TAX,-- "1-90 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '90+ days'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL 
    END     MT_90_PLUS_DAYS,-- "90+ Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '90+ days'
        THEN invoiced_amt_info.CURRENT_TAX
       ELSE NULL
    END     MT_90_PLUS_DAYS_TAX,--"90+ Days Tax",
    uc.UNAPPLIED_CASH UNAPPLIED_CASH--"Unapplied Cash"
    FROM
    oe_order_headers_all        h,
    hz_cust_accounts            cust_acct,
    hz_parties                  party,
    hz_customer_profiles        cust_prof,
    oe_order_lines_all ola,
    select l.HEADER_ID HEADER_ID,
    l.sold_to_org_id SOLD_TO_ORG_ID,
    sum(nvl(l.ORDERED_QUANTITY,0) * nvl(l.UNIT_LIST_PRICE,0)) BOOKED_NOT_BILLED
    from
    oe_order_lines_all l
    where
        l.BOOKED_FLAG <> 'N'
    AND l.FLOW_STATUS_CODE <> 'CANCELLED'
    AND l.INVOICE_INTERFACE_STATUS_CODE <> 'NO'
    group by l.HEADER_ID, l.sold_to_org_id
    ) ola2,
    select INV_AMT.aginglayer, INV_AMT.aging TERMS, sum(INV_AMT.due_amount) CURRENT_INV, INV_AMT.CUSTOMER_ID,--due_amount,--invoiced ammount Currrent
              sum(INV_AMT.tax_amount) CURRENT_TAX --tax_amount
               from (
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , 'Current' aging
                          , 1 aginglayer
                          , 1 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) < 1
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    union
                    select   
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '1-30 days' aging
                          , 2 aginglayer
                          , 2 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) >= 1
                       and trunc(sysdate - ps.due_date) <= 30
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID                     
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '31-60 days' aging
                          , 3 aginglayer
                          , 3 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 30
                       and trunc(sysdate - ps.due_date) <= 60
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '61-90 days' aging
                          , 4 aginglayer
                          , 4 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 60
                       and trunc(sysdate - ps.due_date) <= 90
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID                        
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '90+ days' aging
                          , 5 aginglayer
                          , 5 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                          , ra_customer_trx_all trx
                          , ra_cust_trx_types_all types
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 90
                       and ps.customer_id = c.customer_id
                       and trx.customer_trx_id = ps.customer_trx_id
                       and types.cust_trx_type_id = trx.cust_trx_type_id
                       and types.name <> 'CSG-Conversion Pmt'
                       and types.org_id= 1
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    ) INV_AMT
                 group by aginglayer, aging, showord, INV_AMT.CUSTOMER_ID
    ) invoiced_amt_info,
    select   ra_cust.customer_name CUSTOMER_NAME, ra_cust.customer_number CUSTOMER_NUMBER, ra_cust.customer_id CUSTOMER_ID,
                     sum(pay_sched.amount_due_remaining) UNAPPLIED_CASH
               from  ra_customers ra_cust
                    , ar_payment_schedules_all pay_sched
               where
                 pay_sched.status = 'OP'
                 and pay_sched.class = 'PMT'
                 and pay_sched.due_date > trunc(sysdate - 365)
                 and pay_sched.customer_id = ra_cust.customer_id
               group by ra_cust.customer_name, ra_cust.CUSTOMER_NUMBER, ra_cust.CUSTOMER_ID
    ) uc,
    select   qh.cust_account_id CUST_ACCOUNT_ID,    sum(qh.total_quote_price) OUTSTANDING_SALE_AMT
    from ASO_QUOTE_HEADERS_ALL qh,ASO_QUOTE_STATUSES_TL st
    where st.quote_status_id = qh.quote_status_id
    and st.meaning ='Credit Hold'
    group by qh.cust_account_id
    ) osa          
    Where 
         h.HEADER_ID = ola.HEADER_ID
    AND h.HEADER_ID = ola2.HEADER_ID
    AND ola.sold_to_org_id = cust_acct.cust_account_id(+)
    AND ola2.sold_to_org_id = ola.sold_to_org_id(+)
    AND cust_acct.party_id = party.party_id(+)
    AND cust_acct.CUST_ACCOUNT_ID = cust_prof.CUST_ACCOUNT_ID(+)
    AND cust_prof.party_id = party.party_id
    AND cust_prof.CUST_ACCOUNT_ID = invoiced_amt_info.CUSTOMER_ID(+)
    AND cust_prof.CUST_ACCOUNT_ID = uc.CUSTOMER_ID(+)
    AND cust_prof.CUST_ACCOUNT_ID = osa.CUST_ACCOUNT_ID(+)
    group by  party.party_name, cust_acct.account_number, invoiced_amt_info.TERMS, osa.OUTSTANDING_SALE_AMT,
    ola2.BOOKED_NOT_BILLED,
    invoiced_amt_info.CURRENT_INV,
    invoiced_amt_info.CURRENT_TAX, uc.UNAPPLIED_CASH
    order by party.party_name

    Example
    --Sample Data
    SQL>select deptno, empno, sal,
      2     max(sal) over ( partition by deptno order by deptno) mv
      3* from emp
    SQL> /
        DEPTNO      EMPNO        SAL         MV
            10       7782       2450       5000
            10       7839       5000       5000
            10       7934       1300       5000
            20       7566       2975       3000
            20       7902       3000       3000
            20       7876       1100       3000
            20       7369        800       3000
            20       7788       3000       3000
            30       7521       1250       2850
            30       7844       1500       2850
            30       7499       1600       2850
            30       7900        950       2850
            30       7698       2850       2850
            30       7654       1250       2850
    14 rows selected.
    SQL>select * from
      2  (
      3  select deptno, empno, sal,
      4     max(sal) over ( partition by deptno order by deptno) mv
      5  from emp
      6* ) where sal = mv
    SQL> /
        DEPTNO      EMPNO        SAL         MV
            10       7839       5000       5000
            20       7902       3000       3000
            20       7788       3000       3000
            30       7698       2850       2850SS

  • Transposing group from rows to column

    Hi Team,
    I am having groups of rows of a fixed kind that need to be transposed to column. eg
    Attrib 
    Value
    Attribute1
    a
    Attribute2
    b
    Attribute3
    c
    Attribute4
    d
    Attribute1
    e
    Attribute2
    f
    Attribute3
    g
    Attribute4
    h
    Attribute2
    i
    Attribute3
    j
    Attribute4
    k
    This need to be transposed as ;
    Attribute1
    Attribute2
    Attribute3
    Attribute4
    a
    b
    c
    d
    e
    f
    g
    h
    NULL
    i
    j
    k
    Any help would be great...
    I tried using  PIVOT like
    pivot (min (AttributeValue) for rn in ([1], [2], [3], [4],[5], [6])) pvt  
    where i was having rank in rn... but the places where Attribute1 is not present, that also nneed to become NULL. This is something I am not able to do.

    Hi 
    If
    I may, there is very small fix to
    Rishabh's query in order to make it work.
    * as it is it will work only if the order of the insert fit the result, and not in any case! the SQL Server might bring the data in different order if there is no use of ORDER BY
    Option 1: 
    ;with cte as
    SELECT * , ROW_NUMBER () OVER (partition by Attrib ORDER BY (SELECT NULL)) as rnum
    FROM T
    --select * from cte
    select [Attribute1],[Attribute2],[Attribute3],[Attribute4]
    FROM
    SELECT Attrib,Value , rnum
    FROM cte
    )p
    PIVOT
    (MAX(value) FOR Attrib IN ([Attribute1],[Attribute2],[Attribute3],[Attribute4]))pvt
    Option 2: Another option for solution might be
    ;with MyCTE as (
    select Attrib, Value, ROW_NUMBER() OVER (partition by Attrib order by (SELECT NULL)) RN
    from T
    select
    MAX(CASE when Attrib = 'Attribute1' then Value END) as Attribute1
    ,MAX(CASE when Attrib = 'Attribute2' then Value END) as Attribute2
    ,MAX(CASE when Attrib = 'Attribute3' then Value END) as Attribute3
    ,MAX(CASE when Attrib = 'Attribute4' then Value END) as Attribute4
    --, RN
    from MyCTE
    group by RN
    And here is all together (check your solution which is the first, it will not bring the correct result since I changed the order of inserted)
    create table T (Attrib NVARCHAR(100), Value NVARCHAR(10))
    insert T values
    ('Attribute1', 'a'),
    ('Attribute2', 'b'),
    ('Attribute3', 'j'),
    ('Attribute3', 'c'),
    ('Attribute4', 'd'),
    ('Attribute1', 'e'),
    ('Attribute2', 'f'),
    ('Attribute3', 'g'),
    ('Attribute4', 'h'),
    ('Attribute2', 'i'),
    ('Attribute4', 'k')
    GO
    ;with cte as
    SELECT * , (ROW_NUMBER () OVER (ORDER BY (SELECT NULL)) -1 )/ 4 as rnum
    FROM T
    --select * from cte
    select [Attribute1],[Attribute2],[Attribute3],[Attribute4]
    FROM
    SELECT Attrib,Value , rnum
    FROM cte
    )p
    PIVOT
    (MAX(value) FOR Attrib IN ([Attribute1],[Attribute2],[Attribute3],[Attribute4]))pvt
    GO -- Not OK
    ;with MyCTE as (
    select Attrib, Value, ROW_NUMBER() OVER (partition by Attrib order by (SELECT NULL)) RN
    from T
    select
    MAX(CASE when Attrib = 'Attribute1' then Value END) as Attribute1
    ,MAX(CASE when Attrib = 'Attribute2' then Value END) as Attribute2
    ,MAX(CASE when Attrib = 'Attribute3' then Value END) as Attribute3
    ,MAX(CASE when Attrib = 'Attribute4' then Value END) as Attribute4
    --, RN
    from MyCTE
    group by RN
    GO -- OK
    ;with cte as
    SELECT * , ROW_NUMBER () OVER (partition by Attrib ORDER BY (SELECT NULL)) as rnum
    FROM T
    --select * from cte
    select [Attribute1],[Attribute2],[Attribute3],[Attribute4]
    FROM
    SELECT Attrib,Value , rnum
    FROM cte
    )p
    PIVOT
    (MAX(value) FOR Attrib IN ([Attribute1],[Attribute2],[Attribute3],[Attribute4]))pvt
    GO --OK
    drop table T
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Searching for code for giving headings to certain group of rows dynamically

    Hi All,
    We have a requirement of giving headings to the group of rows.
    For eg: there are three categories A,B&C. under each category the query returns say a set of 3 rows each. Now we have the requirement of arranging these rows under proper category with headings A,Bor C.We can look at this scenario in this way also. suppose category A is apples having 3 rows with data apple and its colour. Next is category B- Mangoes with data mango and its colour. similar is the case with C.We have to arrange them properly by giving them headings as A, B or C. These should be arranged one after another in a tabular fashion. How to do this using OAF. We have made different VOs for headings part and details part.
    Thanks
    Pooja

    Pooja,
    Looking at the initial problem statement, My suggestion is to use the row span feature of Advanced table to group rows on row basis.
    But keep in mind, that it supports read only data and there are some other restrictions as well with this approach.
    Another approach to take in case you have updateable fields is to use 3 different tables.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Previous record values displaying in the Group Footer row in the report.

    Hi Friends,
    I have 3 tables
    TableA:(PERNR BEGDA ENDDA are key fields)
    PERNR BEGDA    ENDDA      WERKS
    10001 1/1/2010 12/31/9999 1001
    TableB:(PERNR BEGDA ENDDA SUBTY are key fields)
    PERNR BEGDA    ENDDA       SUBTY  TYPES
    10001 1/1/2010 12/31/9999   01          COMS1
    10001 1/1/2010 12/31/9999   02         COMS2
    TableC:(PERNR BEGDA  ENDDA are key fields)
    PERNR BEGDA  ENDDA        AMNT
    10001 2/2/1997 4/3/2010      1000
    10001 4/4/2010 12/31/9999  2000
    I have joined these table by the key 'PERNR'( like A->B and A->C)
    Groped by the same key 'PERNR'
    My result rows in the report:
    PERNR BEGDA    ENDDA      WERKS  SUBTY  TYPES  BEGDA    ENDDA      AMNT
    10001 1/1/2010 12/31/9999 1001       01         COMS1  2/2/1997 4/3/2010    1000
    10001 1/1/2010 12/31/9999 1001       02         COMS2  2/2/1997 4/3/2010    1000
    10001 1/1/2010 12/31/9999 1001       01         COMS1  4/4/2010 12/31/9999 2000
    10001 1/1/2010 12/31/9999 1001       02         COMS2  4/4/2010 12/31/9999 2000
    But in the report format is like this in the Group Footer row:
    PERNR: 10001                     WERKS:1001
    SUBTY: 02                          AMNT :2000 (Current date)
                                                AMNT :1000 (Previous record)
    I created the format with "Previous" function
    but in the report it is giving the '2000' instead of '1000' in the AMT field
    Please help me, can i use the for loop in the report? or any sugessions?
    Thanks in advance.
    Regards,
    Venkata

    A group footer will dis[lay contents of the last record. You need to sort records to ensure that the last record contains link to your dynamic image.
    Ian

  • Problem with checkbox group in row popin of table.

    In table row popin I have kept Check Box Group.I have mapped  the texts property of checkbox group to the attribute which is under the subnode of the table.the subnode properties singleton=false,selectioncardinality=0-n,and cardinality=0-n.
    if there are 'n' number of records in the table.each record will have its own row popin and in the row popin there is check box group.
    the check box group in the row popin  belongs to that perticular row.
    but the checkboxegroup values in row popins of all the  rows are getting changed to the row which is lead selected.
    The same scenario  (table in the row popin is showing the values corresponding to its perticular row and all the table values in popin are not getting changed to the one lead selected in the main table)is working fine with the table in place of  checkbox group in row popin with datasource property of table  binded to the subnode
    I cant trace out the problem with checkbox group in place of table.
    Please help me in this regard.I have to place check box group in place of table in row popin.
    Thanks and Regards
        Kiran Kumar K

    I have done the same thing successfully with normal check box ui element. Try using check box in your tabel cell editor instead of check box group.

  • How can I do for a row of a query be data provider for a variable?

    Hi friends, I have a problem !
    How can I do for a row of a query be data provider for a variable?
    I need that a value of variable be stored when the user select a row in a query. At the BPS we can do this configuring the variable selector in WIB, and in a WAB how I can do this ?
    Best regards,
    Gustavo Liberado

    In this case when I press the key to call other forms I need to wait for the response in the secondary form and then process the result.That is exactly what a "modal JDialog" (or JOptionPane) are used for.
    Try it. Create a short demo program. All you need is a JFrame with a single button to show the modal dialog. All you modal dialog needs is a single button to close the dialog. After you show the modal dialog add a System.out.println(...) statement in your code and you will see that it is not executed until the dialog is closed.
    Then once you understand the basics you add the code to your real program.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Grouping of rows of internal table.

    Hi all,
    I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
    This pointer variable will then be passed to ALV.
    Help reqd.
    regards.

    hi,
    AT - itab:
    push F1 to look at the documentation for grouping
    then assign the value to a field-symbol.

  • Finding minimum value in each row using dynamic query

    need to find the minimum and maximum value from each row using dynamic query
    [from curr] will be given as input
    Tuky

    DECLARE @t TABLE(a INT,b INT,c INT);
    INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
    SELECT *
    ,      (   SELECT  MAX(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MaxVal 
    ,      (   SELECT  MIN(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MinVal 
    FROM @t;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Totals after every group of rows - formating help

    Hi,
    What I need is to make the cells darker where the totals are after every group of rows. How do I do that?
    Also, I'm trying to remove the fact that they're merged cells for downloading to Excel (on another report for further analytics).
    Ex: a group of rows show multiple opportunities for an account. The Total NSR value (Revenue) for all the rows for the one Account is displayed after the rows and I don't want this on one of our reports.
    Thanks,
    Anita

    Are you talking about some pre-built report or a custom report you have created?

  • Result Rows in a Query

    Hi
    I have sales org, channel, customer and material along with the key figures in the rows
    of the query. I am automatically getting result for each level by default and then the
    overall result. Is there a way in which i can change all the result rows with
    the corresponding text they belong to like the material result, customer result etc.
    Thanks
    Rashmi.

    Hi
    Not Sure, But try replacement path Variable (with Material Result...etc) and the ckf/Formula(total all the Material, channel...etc) for the same to appear the totals Row .
    /people/kamaljeet.kharbanda/blog/2006/12/28/bex-characteristic-variable-with-replacement-path
    Hope it helps and clear

  • Result Row in the query output

    Hi,
    If I restrict a characteristic by hierarchy then I can’t have the result row displayed. If the hierarchy active is removed then the result row gets displayed. All characteristics are marked to show the result row.
    This characteristic is Account Number. If in the query definition I remove the restriction on account numbers and just select hierarchy active and the required hierarchy in the properties then I get the result row in the output. But now it also displays all the unassigned account numbers in a separate node “Not Assigned Account Number (s)”.
    I can’t even restrict it in the output with hierarchy active selected. When I do select filter value in the output the options Include in Selection and exclude from Selection are grayed out and hence can’t select it.
    Please advice on this issue…
    Thank you,
    sam

    Hi Jaya,
    I think you misunderstood my issue.
    My problem is not that i do not want to see the field. But instead, i do not want to see only the results row in the query output.
    I need to have the results to populate a calculation via sumct formula.
    My question is, can sumct be populated if i hide/supress RESULT row ?
    Regards,
    Maili

Maybe you are looking for

  • TRANSFERING MUSIC FROM IPAD TO PC AFTER HARD DRIVE CRASH

    Have just had my crashed Hard Drive replaced. into the same pc. Loaded Itunes OK Can Sync iPad to Pc and download to Ipad But cannot upload my 1980 plus songs to iTunes on new Hard Drive on same computer. When asking to sync I get a warning that it w

  • How to append records between two internal tables

    hi all, im trying to append from an internal table to another internal table with same structure. i tried the following but it overwrites previous contents of i_dest: move i_src to i_dest thanks, sid

  • Unable to see OC4J Instances in ascontrol -- Urgent

    Hi Iam not able to see the OC4J instances running in ascontrol. They are shown in default group as running. adopmnctl status shows the below status as alive. --------------------------------------------------------------+--------- ias-component | pro

  • Cascade filter doesn't seem to reinitialize

    I'm using a cascade filter with butterworth coefficients in the attached vi. There are some values for input I can give the filter such that it causes the output to be an array of NaN. This is fine, except that when I give the filter the exact input

  • Is it possible to read DDP formatted files from disc?

    I need to check some layers in a master file. I know I can read from DLT tape but can I read in a similar way from these files?