How to find the sum of a column

I need to find the sum of a column and use it in a different column. The following is the example.
Column names: Feedback(Good, Avg, Poor), Count(no of good, no of avg, no of poor) and %age(Feedback/sum(feedback))
I want to find the sum in Java class and also calculate the last column in java class.
Please tell me some way to do it.

oh.. ok ..thanks for letting me know.. i will formulate the question in a proper way:
This is what my UI should look like:
Rating Count Percent
Excellent 2 20
Good 6 60
Poor 1 10
Bad 1 10
Now i have the following columns in the data base:
Meaning and feedback_rating.
So the following SQL Query:
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
will give me the result as
rating counted
Excellent 2
Good 6
Poor 1
Bad 1
Now I want a third column as percentage : Earlier we were doing this calculation in the sql query itself, so the query was like
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted,
sum(decode(bcpi.feedback_rating, null, 0, 1))/(max (select count (*) from cmp_cwb_person_info bcpi ,
hr_lookups hrl )) percent
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
Hence the third column (percent) was calculated in the sql query itself.
But now i feel that the performance of the query could be improved if we get the first two columns from the database and the calculate the third column programatically in the java code.
So this is what I want to know. How can i do that?

Similar Messages

  • How to find the sum of an advanced table column?

    Hi All,
    Good Morning..
    I have requirement where i need to calculate the sum of a column in an advanced table.and i need to put that value into some other field.
    i am doing customization so i can't touch the Standard page properties.so i need to achieve it through Pro-grammatically..
    my column name is unit price in the advanced table region.so i need the code to calculate the sum of the unit price.
    Thanks in advance
    Bharat

    Hi Bharat,
    No need for Programatic way as Advanced Table already provides this facility.
    The following steps describe how to enable Totaling for a column in the footer of an advanced table.
    Step 1: In the Structure pane of OA Extension, select the column container for which you want to enable Totaling Any column except for the first column can be totaled. Set the Total Value property for this column container to True.
    Step 2: In the Structure pane, select your advancedTable region and choose New > footer from the context menu. OA Extension creates an advancedTables Components folder containing a footer named child, that contains a tablefooter container (labeled tableFooter1).
    Step 3: Select the tableFooter container and choose New > total from the context menu. OA Extension creates a tableFooter Components folder containing a total named child, that contains a new totalRow item as shown in the figure below.
    Please let me know if you are still unable to get the Total Column
    HTH,
    Regards,
    Syed.

  • How to find the sum based on two variables

    Hello!
    I have just started using Numbers, I have a spreadsheet which lists a number of transactions.
    On my chart I have Columns "Date", "Memo", "Type", and "Amount".
    The Type column is a drop down list. What I want to do and find the sum for transactions that fall between a date range (i.e. months 1-3) and that match a certain "Type". I can figure out how to use the sumif function to find the sum for a date range, however I cant figure out how then to only sum only those that match a type.
    Any help?

    Brendon,
    This question arises from time to time in different situations. The answer is to first create an auxiliary column which calculates whether or not your multiple conditions have been met. In this case you have three - more than or equal a start date, less than or equal an end date, and a "Type".
    I'm assuming that your dates and "type" are flexible, so an extra table to enter your search data is shown below, but these three cells could be incorporated in your main table. The formula for the auxiliary column is:
    =IF(AND(Date>=Search Range :: A$2,Date<=Search Range :: B$2,Type=Search Range :: C$2),"SUM","")
    All rows with the word "SUM" satisfy the three conditions. The footer row contains the sum of the values meeting the desired conditions using:
    =SUMIF(Aux, “SUM”, Amount)
    Obviously this has to be reworked to your situation, but the auxiliary column is the key.
    pw
    Message was edited by: pw1840

  • How to find the new tables and columns in a schema

    hi..good morning to all...
    I have a schema ABC which owns some objects.
    Now some days before I have made another schema XYZ which was a replica of ABC schema.
    between these days some new tables, new columns in the existing tables(with or without default value), comments on the columns are being added in the new schema i.e XYZ schema.
    Now I have to find the extra things which are present in the new schema. I need to find the new tables, new columns in hte existing tables, their default values and descriptions of those.
    Can u plss help me how can I find it?
    I am guessing that I have to write a SQL query with a minus clause but I am not able to write it and also dont know where should I execute it.
    plss help. thanks in advance.

    And moreover, when I am executing the query to get the desired result, then it is throwing "illegal use of long datatype" error and pointing to the b.data_default area of my query..
    select a.table_name, a.column_name, b.data_default, a.comments from all_col_comments a, dba_tab_columns b
    where a.TABLE_NAME=b.TABLE_NAME
    and a.OWNER=b.OWNER
    and a.OWNER=XYZ
    minus
    select c.table_name, c.column_name, d.data_default, c.comments from all_col_comments c, dba_tab_columns d
    where c.TABLE_NAME=d.TABLE_NAME
    and c.OWNER=d.OWNER
    and c.OWNER='ABC'
    order by 1, 2;
    plss help...

  • How to get the sum in appropriate column without a red triangle appearing?

    Hello,
    In 'Numbers" - How do get columns to add (calculate) the sum in each decending column on an Expense Report.
    When I highlight the decending column the total appears on the far left of the screen.  When I drag the sum amount from there to the appropriate column a red triangle with an ! appears instead of the amount.
    Thanks for your immediate help.

    The red triangle is an Error triangle. Clicking it will display the error message and tell you what error has occurred. From your description, my assumption is that you dragged the SUM() function from the quick calculations at the lower left and dropped it intto a cell in the column being summed.
    If that's the case, this is likely the error message you would see:
    When you highlighted the 'decending column,' you likely selected all of the cells in that column, including the one into which you dropped the function.
    Instead, do one of the following. These assume the column you want to sum is column B.
    If you want the sum at the top of the column:
    Make sure the row you want the sum to appear in is a Header row.
    Enter this formula into any Header Row cell in column B:   =SUM(B)
    If you want the sum at the bottom of the column:
    Add a Footer row to the table. (Go Table (menu) > Footer Rows > 1).
    Enter this formula into the Footer Row cell in column B:   =SUM(B)
    SUM (and other functions) that expect a range of cells will interpret a cell reference entered using only the column letter (B) as meaning 'all of the non-header, non-footer cells in column B', and will exclude those cells in header or footer rows.
    Regards,
    Barry

  • How to get the sum of  a column in a table layout region

    i have page table layout region and i have many rows in that ...i have a column say xyz now i want the sum of all xyz in all rows ...is that possible ..if it is how..????
    please help me out in this issues...so that i can proceed further with my work..im stuck otu here....if the solution r there in the devguide please tell me where it is ..i mean under which section...bcoz it 1400page document...

    If you are mentioning about table/advanced table region you can enable totalling in those regions. Please check the Table / Advanced Table section as appropriate in Chapter 4 of the dev guide.
    If it is not a table / advancedTable then you will have to programmatically total the column value and display it in the appropriate cell.

  • How to find the difference of two columns in deski

    Hi Everyone,
    I have a deski report which is build from a single query. The report contains two tables.
    Table-1:MTK Loc
               MTKnet
    Table-2:WTK Loc
                WTKnet
    Now i need to find the difference of the columns WTKnet and MTKnet.
    These two are report level variables.Their definitins are as  below:
    MTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vMTKLocation>
    WTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vWTKLocation>
    Where <Fees Collected by Per Collected> is universe variable.
    Please help...
    Thanks in Advance......

    Hi Bol,
    As I understand you are taking MTK_Loc and WTK_Loc together in  the report which have common values under Fees Collected by Per Collected  column.
    Please follow the steps mentioned below:
    1.  Calculate the Variables MTK_Net as
           =Sum(<Fees>) IN <MTK_Loc>
    2.  Calculate the Variables WTK_Net as
           =Sum(<Fees>) IN <WTK_Loc>
    3. You will get the values based on the Locations MTK_Loc and WTK_Loc .
    You are using combination of values for MTK_Loc and WTK_Loc hence you will get the variable values in combination.
    Insert new column right to the WTK_Net and  write the formula name it Variance.
    =<MTK_Net>- <WTK_Net>
    The values look like :
    MTK_Loc      WTK_Loc             MTK_Net                 WTK_Net             Variance
    Chicago           Chicago                16,696,274.43      157,168.26            16,539,106.17
    Chicago           Madison               16,696,274.43       274,396.12            16,421,878.31
    Chicago           Milvaki                 16,696,274.43       16,622,870.97       73,403.46
    Chicago           Pennsylvania        16,696,274.43        4,299.35               16,691,975.08
    Chicago           Waukesha             16,696,274.43        22,067.08             16,674,207.35
    Here you will see values for MTK_Net are repeated because these are based on the MTK_Loc which is same for all rows i.e. Chicago , same is the case with remaining values of MTK_Loc.
    We can not calculate variabnce based on the values like Canada,Pennsylvania for all values as these values come in combination of each other and as these are all connected columns WEBI groups  Measure data based on the Dimension  and variable columns associated with it.
    MTK_Loc   WTK_Loc          MTK_Net         WTK_Net          Variance.
    Chicago        Chicago           16696274.43        157168.26           16539106.17
    However you can compare the values based on the values  as :
    1. Drag and Drop MTK_Loc and MTK_Loc separately on the report.
    2. Drag and Drop WTK_Loc and WTK_Loc separately and put it on the report, Connect it to the columns MTK_Loc and MTK_Loc columns already dragged. Then you can compare the values
    MTK_Loc                MTK_Net                         WTK_LOC                    WTK_Net
    Chicago                    16,696,274.43                 Chicago                       157,168.26
    Madison                   315,705.91                       Madison                      274,396.12
    Manitowoc              362,632.50                        Manitowoc                  359,978.50
    Milvaki                    54,172.84                          Milvaki                       16,622,870.97
    Pennsylvania             2,966.56                           Pennsylvania               4,299.35
    Waukesha                 9,028.03                          Waukesha                      22,067.08
    Here I unchecked the option avoid duplicate row aggregation (select table-> format table) thatu2019s why it is showing all values as a  sum of all MTK_Net and WTK_Net values corresponding to Location values..
    Here we are using MTK_Loc and WTK_Loc separately and not connected because though values seems same but they are used in combination ( Chicago, Pennsylvania)  in 2 separate tables in DB hence we canu2019t synchronize them by liking these 2 location columns using 2 data providers.
    I Hope this is what you want....
    Thanks....
    Pratik

  • How to find the Sum based on Like Dates

    Hello everyone,
    Column 1 contains "Date Sent", Column 2 contains "Dates of Service" and Column 3 contains the payment "Amount" in USD. I want to write a formula that will total up the sum of payment values from column 3 based on the date of payment (Column 1).
    Thanks!
    Jared

    Hi Jared,
    This will do what's illustrated in your example, but has a few restrictions:
    The dates must run in ascending order.
    To get a total for the last date, a later date (with no corresponding amount) must be entered after the last transaction.
    Formula:
    Entered in D2, and filled down the rest of column D:
    =IFERROR(IF(A3>A2,SUMIF($A,A2,C),""),"")
    IFERROR is used to suppress the error message that arises from the formula in D10 referencing a cell in D11.
    Regards,
    Barry

  • How to multiply the sum of a column times a £0.20

    Sorry but i am new to mac and numbers,
    i cant seame to make this work in numbers (works fine in excel)
    what i need is: i need to sum column B times (i.e. £0.20.
    i am sure this is very simple but for the life in me i cant get this to work.
    Thanks for your help

    ok, pic bellow
    in the first table i enter:
    clients names, staff attending, amount of hours worked at this client and the date that the staff attended (service date) and last on column F is just a smal formula to give me the month in a number (such as January=1, May=5, etc)
    The table bellow i need to seperate the information gathered on the first table
    such as;how many hours did Barbora worked in january, and then february etc
    and then same for all the names bellow?
    please let me know if you need any more info or screen shoots
    Thanks

  • How to calculate the sum of multiple columns and enter it into a single col

    I have a table tab_contributions which has the following columns:
    Emp_code Current_month(format: yyyymm) Contribution_amt
    Sample entry:
    Emp_code Current_month Contribution_amt
    100 200910 100
    100 200911 100
    100 200912 100
    100 200912 100
    100 201001 100
    100 201002 100
    100 201003 100
    Desired output: Table_result
    Emp_code Years Contribution_amt
    100 2009-2010 700
    Also, the years duration should be of only one year. For eg: 2008-2009, 2009-2010 etc.
    Edited by: user9027633 on Feb 26, 2010 12:34 AM

    Select Emp_code, min(substr(Current_month,1,4))||'-'||max(substr(Current_month,1,4)) period, sum(Contribution_amt) amount
    from mytable
    group by Emp_code;
    SQL> with mytable as (
      2  select 100 Emp_code, 200910 Current_month, 100 Contribution_amt from dual union all
      3  select 100, 200911, 100 from dual union all
      4  select 100, 200912, 100 from dual union all
      5  select 100, 200912, 100 from dual union all
      6  select 100, 201001, 100 from dual union all
      7  select 100, 201002, 100 from dual union all
      8  select 100, 201003, 100 from dual)
      9  Select Emp_code,
    10         min(substr(Current_month,1,4))||'-'||
    11         max(substr(Current_month,1,4)) period,
    12         sum(Contribution_amt) amount
    13  from mytable
    14  group by Emp_code;
      EMP_CODE PERIOD        AMOUNT
           100 2009-2010        700Max
    http://oracleitalia.wordpress.com
    Edited by: Massimo Ruocchio on Feb 26, 2010 9:11 AM
    Added example

  • How to find the duplicate entries in column

    clolum name descripitoin ex:
    CLIENT_NAME | Last Name | First Name | Middle Name |suffix | Tendulkar Sachin Ramesh Jr.Sachin
    | | Sachin Tendulkar Ramesh Jr.Sachin
    | | Ramesh Sachin Tendulkar Jr.Sachin
    PANno | no | AUBIU1966E
    Address | Address of clint | Any address
    Insert multiple records as per the e.g. shown in table. Write a oracle procedure in database schema to input the string and identify the possible duplicates from above table.

    942919 wrote:
    HI
    but clint name is like
    CLINT_NAME
    Sachin Tendulkar Ramesh
    Sachin Ramesh Tendulkar
    Tendulkar Sachin Ramesh
    in this senario clint name column show diffrent names
    your query is not working
    above three entries are same we need to find aboue three entries are duplicate1. Have one other column called Name2 in the table
    2. scan the table and run the "combined" (means you combined every row from below separated by a space) the below output into name2 column
    with t as (
         select 'Sachin Tendulkar Ramesh' col from dual
         select TRIM(substr (splitted,
              instr (splitted, ' ', 1, level ) + 1,
              instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 )) as ret_row
         from (select ' '||col||' ' splitted
         from t)
         connect by level <= length(splitted)-length(replace(splitted,' ',''))+1
         and instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 > 0 order by 1;
    3. now run this
    select name2,count(*)
    the same like above but group by name2, then you will see it

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • How do you get the sum of two columns multipied together?

    I can't seem to figure out how to get the sum of two columns multiplied together without having to manually type out each location (example: A1*B1+A2*B2+A3*B3, etc..).  Though the idea seems to be rather simple, everything I have tried has only given me an error.  I know there must be an easier way of doing this, but I get lost in the explanations given in 'help' area of numbers, can someone help me?

    C3=SUMPRODUCT(A3:A18, B3:B18)
    the function SUMPRODUCT() takes ranges and multiplies corresponding cells in the ranges, then adds them together.
    I the case I show SUMPRODUCT() performs:
    A3*B3 + A4*B4 + A5*B5 + A6*B6 + ... +  A18*B18
    If you want to perform the same operation on the whole column (s) you could modify the formula:
    C3=SUMPRODUCT(A, B)

  • How to find the number of columns in an internal table DYNAMICALLY ?

    Hi,
    How to find the number of columns in an internal table DYNAMICALLY ?
    Thanks and Regards,
    saleem.

    Hi,
    you can find the number of columns and their order using
    the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = sy-repid
      changing
        ct_fieldcat                  = IT_FIELDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif
    now describe your fieldcat . and find no of columns.
    and their order also..
    regards
    vijay

  • How to find the Data Type of a column

    Dear All,
    How to find the Data Type of a Column dynamically in oracle Form.
    Thanks and Regards,
    Fazil
    Edited by: user11334489 on Aug 25, 2012 9:06 PM

    hi,
    you can use get_item_property built-in
    eg:
    declare
       l_item VARCHAR2(10);
    begin
       l_item := Get_Item_Property('item_name',DATATYPE);
    end;

Maybe you are looking for

  • Error during mapping service, RFC-XI-File Adapter

    Hello,   I have the following problem: I am using RFC to send some data to XI and then to File Adapter, however I get a short dump with "5990 Error during mapping service in XI". Even though mappings works, I tested using the document that comes in X

  • "Copy items" command creates new folders on clients

    I'm using ARD 3.1 admin and client on the computers at our school. I've noticed that when I try to copy items to clients, incorrect locations are being created on the client machines. For example, when I specified a path such as users/teacher/sites,

  • Adobe Muse e-commerse with BC

    Hey Guys, I know this has been asked one billion times however I can't seem to find a straight answer. A client of mine is looking to open an online store and I'm looking to do this with Muse & BC. I've watched this tutorial (http://tv.adobe.com/watc

  • How to update PowerPC apps after installing Lion OS X?

    I need to update my PowerPC apps after installing Lion OS X, and if not find a way to run them on Lion using a patch, emulator, converter or otherwise? All help appreciated, thanks for reading. Please note, I do not curretny have a hard-copy of Lion

  • When I try to download netflix app it just freezes and won't download. What am I doing wrong?

    How do I get netflix app to download? When I try iot stops at "Netflix will now begin download". Then nothing happens. I push ok but it won't respond. I went to the netflix site and it said to get some activation code from my device and enter it on t