Aggregate fuction with group by clause

Hello,
Following is assignment is given but i dont get correct output 
so please i am request to all of us write code to solve my problem.
There can be multiple records for one customer in VBAK tables with different combinations.
Considering that we do not need details of each sales order,
use Aggregate functions with GROUP BY clause in SELECT to read the fields.
<garbled code removed>
Moderator Message: Please paste the relevant portions of the code
Edited by: Suhas Saha on Nov 18, 2011 1:48 PM

So if you need not want all the repeated records, then you select all the values to an Internal table,
and declare an internal table of same type and Usee COLLECT
for ex:
itab1 type  <xxxx>.
wa_itba like line of itab1.
itab2 type  <xxxx>. "<-This should be same type of above.
select * from ..... into table itab1.
and now...
loop at itab1 into wa_itab.
collect wa_itab1 into itab2.
endloop.
then you will get your desired result..

Similar Messages

  • Custom IKM Knowledge Modules are not working with Group By Clause

    Hi All,
       I am facing an issue with custom IKM knowledge modules. Those are IKM Sql Incremental Update and IKM Sql Control Append.
    My Scenario is
    1. Created an interface with table on source and temporary datastore with some columns in target.
    2. In the Interface on the target i defined one column as UD1 and other column as UD2  for which group by to be implemented .
    3. Customized  IKM Sql Incremental Update  with " Group by " by making  modification in my IKM Sql Incremental Update
    detail step "Insert flow into I$ table"  i.e., i replaced like this whereever i find this <%=odiRef.getGrpBy()%> API
    Group By
    <%=snpRef.getColList("","[EXPRESSION]","","","UD1")%>,
    <%=snpRef.getColList("","[EXPRESSION]","","","UD2")%>
    Up to UD5.
    . Here in the place of [EXPRESSION] i passed column names for UD1 similarly other column name for [EXPRESSION] of UD2.
    4.Made all the proper mappings and also selected the KM's needed for that interface like CKM Sql ,IKM Sql Incremental Update.
    5. Executed the Interface with global context.
    Error i am getting in this case is :
    Caused By: java.sql.SQLSyntaxErrorException: ORA-00979: not a GROUP BY expression
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115)
    Here the columns in the select clause are there in Group By also.
    I did the same scenario using IKM Sql to file append .In that case i am able to do it. But not with the above mentioned KM's. Please let me know if any one know it or tried with this, as it is
    high priority for me.
    Please help me out.
    Thanks,
    keerthi

    Hi Keerthi,
    If your are transfering data from Oracle to Oracle (I means source is oracle Db and target is also oracle DB) then use below KM's and group by will come automatically based on the key values you selected on interface target datastore
    1) CKM Oracle
    2) LKM Oracle to Oracle (DBLINK)
    3) IKM Oracle Incremental Update (MERGE)
    Hope this will helps to resolve your issue
    Regards,
    Phanikanth

  • Analytic Functions with GROUP-BY Clause?

    I'm just getting acquainted with analytical functions. I like them. I'm having a problem, though. I want to sum up the results, but either I'm running into a limitation or I'm writing the SQL wrong. Any hints for me?
    Hypothetical Table SALES consisting of a DAY_ID, PRODUCT_ID, PURCHASER_ID, PURCHASE_PRICE lists all the
    Hypothetical Business Question: Product prices can fluctuate over the course of a day. I want to know how much per day I would have made had I sold one each of all my products at their max price for that day. Silly question, I know, but it's the best I could come up with to show the problem.
    INSERT INTO SALES VALUES(1,1,1,1.0);
    INSERT INTO SALES VALUES(1,1,1,2.0);
    INSERT INTO SALES VALUES(1,2,1,3.0);
    INSERT INTO SALES VALUES(1,2,1,4.0);
    INSERT INTO SALES VALUES(2,1,1,5.0);
    INSERT INTO SALES VALUES(2,1,1,6.0);
    INSERT INTO SALES VALUES(2,2,1,7.0);
    INSERT INTO SALES VALUES(2,2,1,8.0);
    COMMIT;
    Day 1: Iif I had sold one product 1 at $2 and one product 2 at $4, I would have made 6$.
    Day 2: Iif I had sold one product 1 at $6 and one product 2 at $8, I would have made 14$.
    The desired result set is:
    DAY_ID                 MY_MEASURE
    1                        6
    1                       14The following SQL gets me tantalizingly close:
    SELECT DAY_ID,
      MAX(PURCHASE_PRICE)
      KEEP(DENSE_RANK FIRST ORDER BY PURCHASE_PRICE DESC)
      OVER(PARTITION BY DAY_ID, PRODUCT_ID) AS MY_MEASURE
      FROM SALES
    ORDER BY DAY_ID
    DAY_ID                 MY_MEASURE
    1                      2
    1                      2
    1                      4
    1                      4
    2                      6
    2                      6
    2                      8
    2                      8But as you can see, my result set is "longer" than I wanted it to be. I want a single row per DAY_ID. I understand what the analytical functions are doing here, and I acknowledge that I am "not doing it right." I just can't seem to figure out how to make it work.
    Trying to do a sum() of max() simply does not work, nor does any semblance of a group-by clause that I can come up with. Unfortunately, as soon as I add the windowing function, I am no longer allowed to use group-by expressions (I think).
    I am using a reporting tool, so unfortunately using things like inline views are not an option. I need to be able to define "MY_MEASURE" as something the query tool can apply the SUM() function to in its generated SQL.
    (Note: The actual problem is slightly less easy to conceptualize, but solving this conundrum will take me much closer to solving the other.)
    I humbly solicit your collective wisdom, oh forum.

    Thanks, SY. I went that way originally too. Unfortunately that's no different from what I could get without the RANK function.
    SELECT  DAY_ID,
            PRODUCT_ID,
            MAX(PURCHASE_PRICE) MAX_PRICE
      FROM  SALES
      GROUP BY DAY_ID,
               PRODUCT_ID
      ORDER BY DAY_ID,
               PRODUCT_ID
    DAY_ID                 PRODUCT_ID             MAX_PRICE             
    1                      1                      2                     
    1                      2                      4                     
    2                      1                      6                     
    2                      2                      8

  • Default Sorting behaviour of Oracle 9i in 11g along with group by clause

    Hi,
    We have recently migrated from 9i to 11g. The reports from application comes in a jumbled fashion. Later we understood when there is a group by clause in the query, the recordset will be sorted by default in 9i and this feature is not available in 11g. Do anyone faced the same issue and resolved at the DB level.
    Only alternate we found is the change in code with addittional order by clause which will take a long time to complete and roll out the same.
    If anyone has got any immediate solution, please let me know.
    Thx in advance.
    Sheen

    Hi,
    A group by can sort (depending on the method of grouping) but it isn't necessary. If you want to sort the output you need the ORDER BY clause. There are different group by mechanismes between 9i and 11g. 10g introduced HASH GROUP BY where in 9i only the SORT GROUP BY existed. The latter gives a sorted set, the first not.
    if you want the same behaviour you can use "_gby_hash_aggregation_enabled parameter" = false, which disables the hash group by.
    Have also a look at the support document "'Group By' Does Not Guarantee a Sort Without Order By Clause In 10g and Above [ID 345048.1]".
    Herald ten Dam
    http://htendam.wordpress.com

  • Strange behavior in inner query with group by clause

    Hi All,
    I found a very strange behaviour with Inner query having a group by clause.
    Please look the sample code
    Select b,c,qty from (select a,b,c,sum(d) qty from tab_xyz group by b,c);
    This query gives output by summing b,c wise. But when i run the inner query it gives error as "not a group by expression "
    My question is - though the inner query is wrong, how is it possible that this query gives output.
    it behaves like -
    Select b,c,qty from (select b,c,sum(d) qty from tab_xyz group by b,c);
    Is it a normal behaviour ?
    If it is a normal behaviour, then how group by behaves inside a inner query.
    Thanks !!

    This case I have tested already and it throws error.
    But why the initial posted query is not throwing
    error even the inner query is wrong.
    In what way oracle behaves for the initial posted
    query?what is the scenario that throws the error? is it at the time when you only run the inner query or the whole query?

  • Reg - Search Form for a VO with group by clause

    Hi,
    I have a Bar graph that displays data based on the Query below.
    SELECT STATUS.STATUS_ID AS STATUSID,STATUS.STATUS,COUNT(SR.SERVICEREQUEST_ID) AS SRCOUNT
    FROM SERVICE_REQUEST SR ,SERVICEREQUESTSTATUS STATUS
    WHERE SR.STATUS_ID = STATUS.STATUS_ID
    GROUP BY STATUS.STATUS_ID,STATUS.STATUS,SR.STATUS_ID
    It displays the count of SRs against a particular status.
    Now I need to add a search form to this graph with customer and date range.
    So we need to add the line below to the where clause.
    "SR.CUSTOMER_ID = :customerId AND SR.REQUESTED_ON BETWEEN :fromDate and :toDate"
    But the columns SR.CUSTOMER_ID, SR.REQUESTED_ON also need to be added to the select clause to create the View criteria for search panel.
    The two columns should also need to be added to the group by clause if we are to add them in the select clause.
    This would not produce the expected results.
    How do I create a search form with the criterias applied only at the where clause.Please help.
    With Regards,
    Guna

    The [url http://docs.oracle.com/cd/E16162_01/apirefs.1112/e17483/oracle/jbo/server/ViewObjectImpl.html]ViewObjectImpl has methods for doing this programmatically (setQuery, defineNamedWhereClauseParam, setNamedWhereClauseParam) that you can use to manipulate the query, the bind variables expected, and the values for the binds.
    John

  • Incorrect warning when parsing query with group by clause

    I am using SQL Developer 4.0.0.13.80 with JDK 1.7.0_51 x64 on Windows 8.1
    I have the following SQL, which works perfectly:
    select substr(to_char(tot_amount), 0, 1) as digit, count(*)
    from transactions
    where tot_amount <> 0
    group by substr(to_char(tot_amount), 0, 1)
    order by digit;
    However, SQL Developer is yellow-underlining the first line, telling me that:
    SELECT list is inconsistent with GROUP BY; amend GROUP BY clause to: substr(to_char(rep_tot_amount), 0, 1), substr(to_char(rep_tot_amount),
    which is clearly wrong.
    Message was edited by: JamHan
    Added code formatting.

    Hello,
    I also have found the same issue with the GROUP BY hint. Another problem I found is that the hint suggests to amend the GROUP BY members to add also constant values that are included in the SELECTed columns and whenever those constants include strings with spaces, it generates an invalid query. Normally, constant values won't affect grouping functions and as such they can be omitted from the GROUP BY members, but it seems SQL Dev thinks it differently.
    For example, if you try the following query:
    SELECT d.DNAME, sum(e.sal) amt, 'Total salary' report_title, 100 report_nr
    FROM scott.emp e, scott.dept d
    WHERE e.DEPTNO = d.DEPTNO
    GROUP BY d.DNAME;
    when you hover the mouse pointer on the yellow hint, a popup will show the following message:
    SELECT list inconsistent with GROUP BY; amend GROUP BY clause to:
    d.DNAME, 'Total, 100
    If you click on the hint, it will amend the group by members to become:
    GROUP BY d.DNAME, 'Total, 100;
    that is clearly incorrect syntax. You may notice that after the change the yellow hint is still there, suggesting to amend further the GROUP BY members. If you click again on the hint, you will end with the following:
    GROUP BY d.DNAME, 'Total, 100;
    , 'Total, 100
    and so on.
    I am not sure if this behaviour was already known (Vadim??), but it would be nice if somebody could file a bug against it.
    Finally when writing big queries with complex functions and constant columns, those yellow lines extend all over the select list and they are visually annoying, so I wonder if there is a way to disable the GROUP BY hint until it gets fixed.
    Thanks for any suggestion,
    Paolo

  • Aggregate functions without group by clause

    hi friends,
    i was asked an interesting question by my friend. The question is...
    There is a DEPT table which has dept_no and dept_name. There is an EMP table which has emp_no, emp_name and dept_no.
    My requirement is to get the the dept_no, dept_name and the no. of employees in that department. This should be done without using a group by clause.
    Can anyone of you help me to get a solution for this?

    select distinct emp.deptno,dname
    ,count(*) over(partition by emp.deptno)
    from emp
    ,dept
    where emp.deptno=dept.deptno;
    10     ACCOUNTING     3
    20     RESEARCH     5
    30     SALES     6

  • Query with group by clause

    Hi all,
    I am struggling with one query.So Just i am giving the example..
    CREATE TABLE test(num NUMBER,val NUMBER,description VARCHAR2(100))
    table having the following data
    num val description
    1 100 first
    1 200 second
    1 300 third
    Now i want to take the sum and discription based on num field..
    i should get like ==> 1 600 first
    my query is...
    SELECT SUM(val),description
    FROM test
    GROUP BY description
    But it's giving all records.because description field is there in select statement..
    I tried two cursors for this case..its o.k
    But Is there any way instead of using two cursors.
    Thanks,

    Not sure what you are trying to achieve here. For the same value of NUM (say 1), you have 3 different values of VAL & DESCRIPTION. Do you want to sum up the VAL values for a particular value of NUM? In that case, what will be the corresponding DESCRIPTION?
    How did you arrive at the result --- 1 600 first
    -- whereas the DESCRIPTION is different for the 3 VAL values?

  • Problem with group by clause

    Hi,
    this is my query
    SELECT inccodrid, inccau, count(*) AS record, sum(incprez) AS prezzo, sum(incpren) AS preno, sum(incprev) AS preve
    FROM incassi
    WHERE incuten='125' And incdemi Between #12/4/2002# And #12/4/2002#
    GROUP BY inccodrid, inccau
    ORDER BY inccau
    when i execute this query with jdbc the runtime give me an error "stato del cursore non valido", but if i try to execute in msaccess the query work fine.... Anyone can help me?
    Problem n 2
    SELECT produzione.proid, inccodrid, inccau, count(*) AS record, sum(incprez) AS prezzo, sum(incpren) AS preno, sum(incprev) AS preve
    FROM (produzione INNER JOIN titoli ON produzione.proid=titoli.titpro) INNER JOIN incassi ON titoli.titid=incassi.incevid
    WHERE produzione.proid=dato And incdemi Between data1 And data2
    GROUP BY produzione.proid, inccodrid, inccau
    ORDER BY produzione.proid, inccau;
    when i execute this query with jdbc he give me one record and no-error, but if i try to execute in msaccess the query work fine and give me 3 record???!!!
    I know that access is not the greatest dbengine in the world, but i need to use it...
    thanks
    Baro

    Can you please post part of your Java Code where you do your database things. maybe i can help you then.

  • Can not use NVL with group by clause?

    Hi All, I am using following sql query to fetch some records. select       nvl('RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc','RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc')||'|'||       nvl(tm_cdr_file_name,'NA')||'|'||       nvl(min(obj_id0),'0')||'|'||       nvl(max(obj_id0),'0')||'|'||       nvl(count(obj_id0),'0')||'|'||       nvl(trim(to_char(sum(VOLUME_RECEIVED)/100,'9999999999999990.99')),'0') from       EVENT_DLAY_SESS_TLCS_T where       obj_id0 between 1433833603724199101 and 1433833603724199109 group by       nvl(tm_cdr_file_name,'NA') The above query is perfect and returns data. In this case the returned data is as below:   RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc|ICP_dsc_dlk_MED_DEL_SBH_20130919_5799.edr|1433833603724199101|1433833603724199109|9|2.00 However, when there is no matching obj_id0. My expected result will be as below:   RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc|NA|0|0|0|0 I tried NVL and decode but it did not work. Any help on this is highly appreciated. Thanks Angsuman

    Hi, Angsuman,
    Angshuman wrote:
    Hi All, I am using following sql query to fetch some records. select       nvl('RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc','RP5_dsc_dlk_MED_DEL_SBH_20130919_5799.out.bc')||'|'||       nvl(tm_cdr_file_name,'NA')||'|'||       nvl(min(obj_id0),'0')||'|'||       nvl(max(obj_id0),'0')||'|'||       nvl(count(obj_id0),'0')||'|'||       nvl(trim(to_char(sum(VOLUME_RECEIVED)/100,'9999999999999990.99')),'0') from       EVENT_DLAY_SESS_TLCS_T where       obj_id0 between 1433833603724199101 and 1433833603724199109 group by       nvl(tm_cdr_file_name,'NA') The above query is perfect ...
    Is the query really perfect, or does it have some problem?
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data, so that the people who want to help you can re-create the problem and test their ideas.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    Do you think the message you posted is easy to read?  Do you think people would be able to understand what you're doing, and be more likely to help you, if it were formatted differently?
    I know this this site can take something that looks nice when you post it, and turn it into something hard to read.  Look at your message after you post it.  If it has become hard to read, fix it, even if the site, not you, caused the problem.

  • Case statement with group by clause

    SELECT STP, CASE WHEN Alternate IS NULL THEN 3 ELSE 4 END as Ind,
    CASE WHEN Alternate IS NULL THEN 'New Address' ELSE 'New Location' END as Description , Count(*) Rec_Cnt
    FROM t_Ids
    group by STP, CASE WHEN Alternate IS NULL THEN 3 ELSE 4 END, CASE WHEN Alternate IS NULL THEN 'New Address' ELSE 'New Location'
    ORDER BY 1,2,3
    I need a query something like this. Does anyone has any idea on this???

    You're missing the END on the GROUP BY Case statement, but otherwise this looks fine.
    What problem are you having?
    Also, please post DDL
    Thanks
    Carl

  • Wrong query is getting generated in WHERE NOT EXISTS  with group by clause

    Query is getting generated wrongly in where not exists section when i use group by function.Please prvoide me any clue to over come the problem.
    /* DETECTION_STRATEGY = NOT_EXISTS */
    INSERT /*+ APPEND */ INTO STG_ETL.I$_DCMT_TIMEZONE_LOOKUP
         TZ_OFFSET,
         ADT_CRT_DT,
         ADT_UPDT_DT,
         IND_UPDATE
    SELECT * FROM (
    SELECT      
         to_number(KOFAX.RECEIVED_TZ)     TZ_OFFSET,
         min(sysdate)     ADT_CRT_DT,
         min(sysdate)     ADT_UPDT_DT,
         'I' IND_UPDATE
    FROM     ESTG.FLAT_FIL_DMS_KOFAX KOFAX
    WHERE     (1=1)
    And (KOFAX.LD_DT = ( select MAX(LD_DT) from ESTG.FLAT_FIL_DMS_KOFAX INNER
    where INNER.ENGAGEMENT=KOFAX.ENGAGEMENT
                   and INNER.KOFAX_FILE_NM = KOFAX.KOFAX_FILE_NM
                   AND INNER.IM_CUST_ID = KOFAX.IM_CUST_ID
              and INNER.BATCH_ID=KOFAX.BATCH_ID)
    AND
    (TO_DATE(KOFAX.LD_DT)>=TO_DATE(SUBSTR('#WAREHOUSE.P_EDW_LAST_RUN',1,10),'YYYY-MM-DD'))
    And (substr(KOFAX.RECEIVED_TZ,1,1) <> '+')
    Group By to_number(KOFAX.RECEIVED_TZ)
    ) S
    WHERE NOT EXISTS (
         SELECT     'X'
         FROM     EDW.DCMT_TIMEZONE_LOOKUP T
         WHERE     T.TZ_OFFSET     = S.TZ_OFFSET AND
         )

    Easiest fix for you would be to change the detection_strategy on the IKM from NOT_EXISTS to either :
    MINUS
    -- Try this out, it should work, it will give the same data through the equiverlant steps.
    NONE
    -- This will load all incoming data into your I$ table, there will be more rows to crunch in the following 'Flag Rows for Update' step, it might give incorrect results potentially - you will have to test it.
    So try MINUS first, failing that, see if NONE gives you what you want in your target.
    Are you inserting only new data or updating existing data?

  • COUNT with Group By clause issue

    Good Morning everyone. I have a simple query that calculates the count of 3 expressions. It is supposed to group by region and province as a result set, but instead places the TOTAL count for each expression in the region and province fields. What am I doing wrong? This is my query:
    SELECT TABLE1."Province",
    TABLE1."Region",
    (SELECT(COUNT(TABLE1."Nationality"))
    FROM TABLE1
    WHERE (TABLE1."Nationality" <> 'United States'
    AND TABLE1."Nationality" <> 'Nat1')
    OR (TABLE1."Medical" <> 'ON MEDICAL'
    AND TABLE1."Region" <> 'CONUS')
    ) "TCN COUNT",
    (SELECT(COUNT(TABLE1."Nationality"))
    FROM TABLE1
    WHERE (TABLE1."Nationality" = 'United States')
    OR (TABLE1."Medical" <> 'ON MEDICAL'
    AND TABLE1."Region" <> 'CONUS')
    ) "US COUNT",
    (SELECT(COUNT(TABLE1."Nationality"))
    FROM TABLE1
    WHERE (TABLE1."Nationality" = 'Nat1')
    OR (TABLE1."Medical" <> 'ON MEDICAL'
    AND TABLE1."Region" <> 'CONUS')
    ) "HCN COUNT"
    FROM TABLE1
    GROUP BY TABLE1."Province",
    TABLE1."Region";
    Any help would be appreciated. Thank you.
    Aqua

    Because you are not passing any values to the inner query from the outer one..
    Are you looking for this?
    SELECT      TABLE1."Province",
         TABLE1."Region",
         sum (
           case when (
                 TABLE1."Nationality" != 'United States'
                 AND TABLE1."Nationality" !=  'Nat1'
                OR (
                TABLE1."Medical" != 'ON MEDICAL'
                AND TABLE1."Region" != 'CONUS'
                 ) then 1 else 0 end
             ) "TCN COUNT",
         sum (
           case when (
                TABLE1."Nationality" = 'United States'
                OR (
                TABLE1."Medical" 'ON MEDICAL'
                AND TABLE1."Region" 'CONUS'
                   ) then 1 else 0 end
             ) "US COUNT",
         sum (
           case when (
                TABLE1."Nationality" = 'Nat1'
                  OR (
                   TABLE1."Medical" 'ON MEDICAL'
                   AND TABLE1."Region" 'CONUS'
                     ) then 1 else 0 end
             ) "HCN COUNT"
    FROM TABLE1
    GROUP BY TABLE1."Province",TABLE1."Region";

  • Problem with the query in group by clause

    hi, i have problem with group by clause, can some one please help me.
    select
    header_id,
    (select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
    where
    a1.country=a.country
    and a1.source='AP'
    and a1.header_id=a.header_id) WHT,
    sum(dr),
    sum(cr) from temp_tab a
    group by header_id,
    (select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
    where
    a1.country=a.country
    and a1.source='AP'
    and a1.header_id=a.header_id)
    select * from temp_tab
    drop table temp_tab
    create table temp_tab(header_id number ,line_num number, country varchar2(2),
    source varchar2(2), dr number, cr number,primary key(header_id,line_num));
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 1,'NL','AP',100,20);
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 2,'PO','AP',20,20);
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(1, 3,'NL','AP',70,20);
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(2, 1,'NL','PA',100,20);
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(2, 2,'NL','PA',100,20);
    insert into temp_tab(header_id, line_num,country, source, dr,cr) values(3, 1,'KR','PO',100,20);
    commit;
    Appreciate your help.
    Thanks,

    select header_id,
             (select sum(nvl(dr,0) - nvl(cr ,0)) from temp_tab a1
             where a1.country=a.country
             and a1.source='AP'
             and a1.header_id=a.header_id) WHT,
             sum(dr),
             sum(cr)
      from temp_tab a
    group by header_id
    ,countryIt's kinda hard to follow what your query does... maybe because I'm only at my second coffee..
    Edited by: Alex Nuijten on Oct 2, 2009 8:07 AM

Maybe you are looking for

  • Views in OBIEE

    Hi experts , I have imported view V from DB. And in BMM Layer i created one dimension A and Fact B from the same view. and check the consistency. t is giving the below warning Logical dimension table A has a source V that does not join to any fact so

  • Meta data not being imported

    Hi, I am using OBIEE 11. I have created an ODBC to a SQL database. I have created a new BI repository in the BI admin tool and chose the odbc as the data source. I selected all metadata types. When I click on the finish the database is in the physica

  • PDFs made through 'reader' button have a narrow margin in Safari 7.0.4

    Hi One thing I like about Safari is its handy feature of converting most webpages to uncluttered, neat PDFs which include only the main text passage with its relevant illustrations. But after the recent upgrade, I noticed two things the second of whi

  • Portion of budget transfer restriction

    Dear Friends, I want to transfer the budget from one fund center to another fund center but the condition is that need to rectrict the portion of the budget from sender fund center. The sender fund center will not allow to transfer that budget portio

  • Every time I put a movie on itunes then it comes to home movies. Howe can i solve this?

    Every time I put a movie on itunes then it comes to home movies. Howe can i solve this?