Sum on a column in a collection based report

Hi all

I have a sql report based on a collection, it comes to my query

Select c001, c002, c003 or c004,
seq_id
of apex_collections
where collection_name = "ADDSERVICES."

Initially, this collection is empty, the user adds the lines in this collection.

as and when the user adds rows to this collection, I want total (sum) of a column, but its always showing 0.

How to get the value of the sum?

Apex4.1
Oracle 11g R2

Concerning
Tauceef

Tauceef wrote:
Hi all

I have a sql report based on a collection, it comes to my query

Select c001, c002, c003 or c004,
seq_id
of apex_collections
where collection_name = "ADDSERVICES."

Initially, this collection is empty, the user adds the lines in this collection.

as and when the user adds rows to this collection, I want total (sum) of a column, but its always showing 0.

How to get the value of the sum?

Apex4.1
Oracle 11g R2

Concerning
Tauceef

Hi Tauceef,

How do you calculate the sum? means on which column? and finally you calculate the sum in a session of apex? (because apex_collections view is related to the current session of the application)

I see that your columns (c001, c002, c003 or c004) are only varchar2, if you are sure that it is a number column then it is best to use the number of columns (n001, n002...)

Thank you

Tags: Database

Similar Questions

  • Any method to create a total SUM of a column whose values based on LAG?

    I have a question here, and the challenge is to explain my situation well. I am developing a workbook that shows by project and month, the cost of this period and the change in the cost of the previous period. I want a total SUM on the columns of this period cost and cost change in prerequisite Mth. So what I want to do resembles something like this--

    Months of project cost this time Chg prior Mth cost

    ABCDE Jan $50,000 NULL (since no line before)
    ABCDE February $ $75,000 25 000
    Mar $60,000 ABCDE - 15 000
    ------------------------ ----------------------------------------------
    Total of $ $185,000 10 000

    I do the Chg of cost of prior Mth as a new calculation and use the formula insert model process to use the model of the difference f (x) to create my calculation. Who is working just great. If you look at the underlying code for this new section, you can see the LAG function used in the calculation of this value. I'm late to a single line, as you can see in the example above.

    I can create a new total and take a NAP in the cost column this time and get the right answer (the $185 000).

    The problem that I am running is that I get nothing when I try to summarize my prior Mth column cost Chg. The result is just empty (prints the text of the total, but no amount).

    My thought is that the NULL row in this column was to spoil the AMOUNT of work. So, I created a new calculation and said CASES WHERE prior cost Chg of Mth IS NULL THEN 0.00 ELSE cost Chg of Mth prior. So I get a new column with the same numbers, except for the first line, where I now have a 0 instead of NULL. Then, I created a new total (SUM function) on this new column. Heck. Same result with regard to the other column. I do not receive an amount.

    Everybody run on an issue to try to sum a column of numbers being calculated from a SHIFT function in discoverer? Any suggestions on how I could get a SUM to calculate correctly to this column cost Chg prior Mth? Or have I met one of those irritating questions "cannot manage in discoverer?

    Of course I can export the workbook results run to Excel and create the calculation in there, and that works fine.

    John Dickey

    Hi John
    Thanks for the question and great information. That really helped. I love this kind of questions. They make me think :-)

    Just a thought but have you tried to change the AMOUNT for a sum of CELL?

    The SUM will try to assess the LAG on the total that would be invalid as, at least in theory, the SUM of the CELL must literally add the values.

    Best wishes
    Michael

  • Calculate the sum of the columns

    Hello!

    Am using jdeveloper 11.1.2.1

    I created a table VO based EO. I need to calculate the sum of the column named price.

    I use the expression PoView.sum ("Price"). In this PoView is the name of VO and the price is the name of the column.

    While spin AMModule I got an exception like

    PoView name not found in the given object.

    Hello

    You must use the name accessor EO or VO instead of the name of VO.
    See https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (there are even the same error message in one of the comments of this blog)

    concerning
    Peter

  • Update of the collection based on (wwv_flow.g_f01) report

    Hi all
    I have a page in my application that contains 3 standard reports based in a collection. There is a main report and from there you explore the other report, and from there you can go down to another (3rd report) that I'm trying to update a member of the collection based on an lov. I don't know how to insert the value from the lov in the 3rd report.


    Select seq_id
    IN CURR_SEQ_ID
    of apex_collections
    where collection_name = "ARGYLL_INVOICES."
    and c001 | C002 =: P12_EPSB_JE_HEAD_LINE_NUM;

    apex_collection.update_member_attribute (p_collection_name = > 'ARGYLL_INVOICES',)
    p_seq = > CURR_SEQ_ID p_attr_number = > 17, p_attr_value = > "EDMO");

    It works fine, but of course, it is hard coded. I would use the api wwv_flow.g_f01 but I can't make it work with my rudimentary understanding of this api call.

    apex_collection.update_member_attribute (p_collection_name = > 'ARGYLL_INVOICES',)
    p_seq = > CURR_SEQ_ID p_attr_number = > 17, p_attr_value = > wwv_flow.g_f01 (a few references here);


    Any guidance would be most appreciated.

    Thank you

    Here is an excerpt from a quick tutorial on the use of collections. I'm including the section of the report you can see the corresponding values:

    SELECT rownum, apex_item.hidden(1, c001),  --Key ID
         apex_item.text(2, c002, 8, 8) VALUE1,
         apex_item.text(3, c003, 3, 3) VALUE2,
         apex_item.text(4, c004, 8, 8) VALUE3,
         apex_item.date_popup(5, null,c005,'MMDDYYYY',10,10) MY_DATE
    FROM APEX_COLLECTIONS
    WHERE COLLECTION_NAME = 'MY_COLLECTION'
    

    It will be a report as a SQL report - you are just pulling the data from the collection. You can always ask the nice formatting, naming, sorting, etc. of a standard report. In the report, the user will have 3 values 'text' and a Date with the date picker. You can change the format, make sure just to change all four procedures.

    What is critical to note here are the numbers that come just before the column names. These numbers become identifier in the table used to capture data. What is APEX is creates an array of up to 50 items designated as F01 - F50. The F is static, but the number that follows, it matches the number on your tax report above, IE, F01 will contain the primary key value, F02 will contain the first numeric value, etc.. Although not strictly necessary, it is advisable to assign these values so you don't have to guess.

    A note more: I try to align c00x values in the column with the values of F0X collection in the table to stand straight, but they are values that do NOT have to match. If you have a request that you think could get developed, you can leave gaps where you want. Remember, however, that you have only 50 columns of table to use for the data entry. It is the limit of F0X table even if a collection can have up to 1000 values.

    Now, you need a way to capture the user input. I like to create this as a PRELIMINARY procedure CALCULATIONS/VALIDATIONS in this way the user can see what they changed (even if it is false). Use Validations to intercept errors.

    declare
      j pls_integer := 0;
    begin
    for j1 in (
      select seq_id from apex_collections
      where collection_name = 'MY_COLLECTION'
      order by seq_id) loop
      j := j+1;
      --VAL1 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>2,p_attr_value=>wwv_flow.g_f02(j));
      --VAL2 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>3,p_attr_value=>wwv_flow.g_f03(j));
      --VAL3 (text)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f04(j));
      --VAL4 (Date)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f05(j));
    end loop;
    end;
    

    Clear as mud? Walk slowly through it. The syntax tells APEX Collection (p_collection_name) (p_seq) line, then what attribute/column (p_attr_number) updated with the value (wwv_flow.g_f0X (j)). The number of the attribute is the column number of the collection without the 'c' on the front (IE c004 in the collection = attribute 4).

    See if this helps answer the question. You'll notice that I'm grabbing values SEQ_ID of the collection and a loop through them one at a time and using them to find the index of the JavaScript array holding the corresponding value, I need to use in the update part.

  • How to replace the value of a column in a table based on the value in the second column?

    Hi, I would like to find in a table 2D for values that meet certain criteria (for example, a column< 0.98).=""  based="" on="" which="" rows="" meet="" this="" criteria,="" i="" want="" to="" replace="" the="" values="" in="" a="" different="" column="" of="" the="" array="" (change="" to="" 'nan'="" so="" that="" the="" values="" will="" not="" be="" included="" in="" any="" calculations="" on="" that="" column,="" for="" example="" the="" finding="" the="" mean).=""  i've="" attached="" a="" sample="" .csv="" file.=""  if="" the="" values="" in="" column="" 3="" (index="" 2)="" are="" less="" than="" 0.980="" (or="" some="" other="" user="" defined="" value),="" then="" the="" value="" in="" column="" 2="" (index="" 1)="" should="" be="" replaced="" with="" nan.=""  can="" someone="" help="" out="" with="" this="" search="" and="" replace="">

    Thank you

    Keith

    (using LV 2009 SP1)

    A few quick hits.

    You can merge the two for loops

    You have not need one of the constants 1 and 2 in the index table.  They will solve automatically when you expand on the index picture, once you have wired to 0 in the column index.

    It seems a lot of handling additional table spent unnecessarily.

    See below.  I did not try to duplicate your code to see how it actually works, but I believe that I have attached will give the same result with less steps.

  • Is there an alternative way to compute the sum of a column without accessor view

    Hi Experts,

    JDev 12 c,

    I have a column A and I'm total calculation of column A with the same VO as a view accessor. And calculating as below

    EmployeeViewAccessor.sum ("ColumnA").

    But this way, it loads the VO 2 times as it loads the accessor aswell.

    So is there an alternative way to calculate the sum of a column.

    Thank you

    Roy

    Use the analytical function, please see below Ex

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions163.htm

  • Add the column in the collection

    Hi gurus

    I created 1 collection as below:

    Create the Collection with the type of table emp

    type c_emp is the table emp % rowtype;

    v_emp:=c_emp() c_emp;

    Now I want to add more than 2 columns in this collection, first name of the column is varchar2 (10) and and 2nd name column is varchar2 (10) s but unable to understand how will I achieve this?. Please guide. Thank you

    Concerning

    Shu

    I created 1 collection as below:

    Create the Collection with the type of table emp

    type c_emp is the table emp % rowtype;

    v_emp:=c_emp() c_emp;

    Now I want to add more than 2 columns in this collection, first name of the column is varchar2 (10) and and 2nd name column is varchar2 (10) s but unable to understand how will I achieve this?.

    You cannot change this collection. You must create a new. And you use no reserved words (for example, the "group") for the names.

    DECLARE

    CURSOR c1 IS (SELECT e.*, cast (null as varchar2 (10) GroupName, cast (null as name varchar2 (10))))

    FROM emp e);

    TYPE typ_tbl IS TABLE c1% rowtype;

    v typ_tbl;

    BEGIN

    . . .

  • Calculation of the sum of a column on a XML editor RTF with NULL values

    Hello

    I have a problem to get the sum of a column in XML editor RTF, if one of the lines has a null value.

    say, I have 4 columns and values

    CASES1:
    NULL, NULL, 4, NULL
    Sum, I expect is: 4

    CASE2:
    NULL, NULL, NULL, NULL
    I'm waiting for is a null

    Is there a way to do this?

    Thank you
    Anita

    Try this

    AMT's column

  • Select the distinct value of a column in the collection in bulk.

    Hi all

    Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.

    Collection has followiing values inside.
    Col(c).articleid,
    Col(c).userkey,
    Col(c).origin,
    Col(c).addnlorigindata,
    Col(c).avdest,
    Col(c).dispfmt,
    Col(c).sourcecode,
    Col(c).success_ind,
    Col(c).error_code,
    Col(c).entry_createddate,
    Col(c).createdby,
    Col(c).filenumber,
    Col(c).linenumber,
    Col(c).acctnum,
    Col(c).assetkey,
    Col(c).autocompletedterm,
    Col(c).accessionnumber,
    Col(c).requestdatetime,
    Col(c).requestorip,
    Col(c).articleordinal,
    Col(c).userinitiatedind,
    Col(c).captchastatus
    I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.

    Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.

    Thanks n regards
    Nana Akkivalli.

    The collection must be inserted before you can use this topic.

    In the Begin block, you have to collect a loose and insert inside: something like

    SELECT *
    BULK COLLECT INTO l_array
    FROM ALL_USER
    ...CONDITIONS...
    
  • A simple query to write for the SUM of a column

    Hello

    I have a Quantity column. I want his total.
    For a PURCHASE, I would like to add the value in the column Qunatity.
    For a COPY, I want to subtract the value in the column Qunatity.
    So overall, the sum of the column should give me total buy less total sells.

    Any help is welcome.
    Thank you.

    Published by: TechVortex on August 11, 2011 11:49

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with sample_data as
      2  (
      3  select 100 quantity, 'B' flag from dual union all
      4  select 200, 'B' from dual union all
      5  select 100, 'S' from dual union all
      6  select 500, 'B' from dual union all
      7  select 200, 'S' from dual
      8  )
      9  SELECT SUM(quantity),
     10         SUM(DECODE(flag, 'B', quantity,
     11                          'S', -quantity)) absolute_sum
     12* FROM   sample_data
    SQL> /
    
    SUM(QUANTITY) ABSOLUTE_SUM
    ------------- ------------
             1100          500
    
  • sum of a column of the dimension

    Hello
    If my requirement of report said we get SUM (Treasury of column) of the dimension table then can we do it? I have undersatnd that function must be used for measures in fact table. What are we doing to reach the sum of the columns in the dimension table? The report tries to compare the sum (column done) sum (dimension columns). Earlier when I used the sum on the column dimension function he gave no precise results. Please advice.

    Unfortunately, I could not explain this matter in a simple unique way, without seeing exactly the report and generated queries

    In the simple table, OBIEE is supposed to do something like this (I assume you put the attribute of the year, money and a measure of 'real')

    "+ select +".
    + Year +.
    + Sum (cash) +.
    + Sum (fact measure) +.

    + Of +.
    + time_dim_table, +.
    + cash_dim_table, +.
    + fact_table +.

    + where (joins).
    + Group by year +.
    "

    You can check if the physical demand looks like this, in order to understand the results.

    In the PivotTable, it's totally different.
    Your physical demand will be no aggregation: so what will:

    "+ select +".
    + Year +.
    + Cash +.
    + Sum (fact measure) +.

    + Of +.
    + time_dim_table, +.
    + cash_dim_table, +.
    + fact_table +.

    + where (joins).
    + Group by year, money +.
    "

    But, OBIEE then apply logic calculatiosn to display goods results in the PivotTable.
    Who can explain the different results.

    But don't forget that told you right: avoid the aggregation on the dimension attributes. You can sometimes has good results (ex: using the pivot, or other), but it's not really the best way to make your reports. If you often need a "sum (cash"), create a new table of logic made with the 'picture of cash' (even if it is also a dimension table).

  • the sum of a column where date column is converted in year + 1

    Hello

    I want the sum, said the column of taAmt where he is not null and the column fromPeriod is converted to the format of the year and has 1 year. This syntax does not work, can anyone help?

    <? sum (taAmt [.! = "and fromPeriod ('YYYY') + 1])? >

    Assigning :) Points If you wish

  • How to adjust column widths individual classic SQL report

    Hello

    I use Oracle APEX v4.2 with IE8 browser and basically tries to adjust widths of individual columns in my classic SQL report. Basically, I have three columns I want to spacing, so that the width of the entire region for the report is used, but am not sure how to proceed.

    I drilled in individual columns and specified the column widths as the element, but in vain.

    Would appreciate help on how to do this for each column and hope that I do not need to change the model of report (if possible).

    Thank you.

    Tony.

    Tony F. says:

    I use Oracle APEX v4.2 with IE8 browser and basically tries to adjust widths of individual columns in my classic SQL report. Basically, I have three columns I want to spacing, so that the width of the entire region for the report is used, but am not sure how to proceed.

    There is an element of uncertainty in what we suggest as well, because you have not specified the theme and the report of model that is used. This information is required for any question of formatting or the visual layout.

    I drilled in individual columns and specified the column widths as the element, but in vain.

    Report in some themes templates may be missing in the #COLUMN_WIDTH substitution string # required for use of the declarative column widths, as shown here: Re: width of column in reports

    I don't know why it would be missing from a theme of so-called "modern" (perhaps the lack of documentation affects even the Oracle theme designers), but you can add it to the models listed in this thread.

    Width of the element applies only to controls on a form in a table.

    Would appreciate help on how to do this for each column and hope that I do not need to change the model of report (if possible).

    This can be done using selectors CSS attribute (for the themes of quirks mode non-traditional, because you are using a legacy version of IE). Add a style sheet in CSS Inline property page:

    #ALIAS,
    td[headers="ALIAS"] {
    width: 40%;
    }
    

    where the ALIAS value in the attribute selector matches the required column alias, and the width property specifies the column dimension required and the units.

    Note that the percentage widths will be compared to the width of the report table. Therefore, it may be necessary to also specify widths (100%) for the table of report and its components. Exactly how is based on the report, the region and the page templates and theme used, information that was not provided.

  • How to add a column of formulas in a report

    Hello
    I made a report based on a query.
    There are 3 columns in the query and all 3 are displayed.
    Now, I want to add a new column (column fomula) to the report.
    I want to write a query within the formula column. To run the query col1, col2 and col3 values are required in the formula column.
    Could you please tell me how to add a column of formulas in the report and how to pass the value of column of data in the formula column
    concerning

    Please see '3.9.1.2 an image or repeating framework' in the following document.

    http://download.Oracle.com/docs/HTML/B13895_01/orbr_howto.htm#i1059697

    In the property inspector of the extensible framework, there is a 'Source' property, use Group second query name here. Vertical elasticity of the framework would be variable.

  • The limit to the number of columns to display in the report. Help!

    Hi all

    Maybe this is a stupid question. But why get this error with a report of the IR? and what is the solution for this. Please help me with this.

    Error

    The limit to the number of columns to display in the report. Please, click on select columns under Actions menu to minimize the list of columns in report view.

    Oh... And I also have a blob column... If the format is not given, the table is very good... but happen to get this error only when the BLOB download format is given.

    Thanks and greetings
    John

    Published by: JB on March 30, 2012 11:08

    Hello

    I implemented a small suitcase of test on apex.oracle.com and I get the error even if I use the download format.

    I have a table
    test_blob (identification number, name varchar2 (10), blobcont blob)

    If I create IR as

      select
        id,
        name,
        blobcont
      from test_blob
    

    and then I set the download format I got the error.

    If you want this to work you need to change your query to

      select
        id,
        name,
        dbms_lob.getlength(blobcont) blobcont
      from test_blob
    

    And there still define download for blob on column blobcont format.

    Kind regards
    Aljaz

Maybe you are looking for