Query to retun the sum total of values
My PO table structure is
PO_no PO_VER_ID PO_TOTL_AMT
1111 1 2000
2222 1 1000
1111 2 100
How do I write a query that will have return me sum(PO_TOTL_AMT) of the PO_NO with max(PO_VER_ID). My Result should be
SUM(PO_TOTL_AMT) = 1100. i.e sum of PO_NO 2222 with PO_VER_ID = 1 and PO_NO 1111 with version 2
Can it be performed by a single SQL query.
Thanks in advance
Regards
WITH t AS (SELECT 1111 po_no, 1 po_ver_id, 2000 po_totl_amt FROM dual
UNION
SELECT 2222, 1, 1000 FROM dual
UNION
SELECT 1111, 2, 100 FROM dual)
SELECT SUM(po_totl_amt)
FROM (SELECT po_totl_amt
, RANK() OVER (PARTITION BY po_no ORDER BY po_ver_id DESC) rnk
FROM t)
WHERE rnk = 1;
Similar Messages
-
Query to find the sum of different groups of same column
Hi ,
I have a table as follows:
customers
custid credit amt month
001 C 2000 Jan-2012
001 D 5000 Feb-2012
001 C 3000 Mar-2012
001 C 3000 Apr-2012
001 D 7000 May-2012
I Have to write a single query to calculate the sum of credit and sum of debit value separately.
Thanks & Regards,
SB2011Hi,
SB2011 wrote:
Hi ,
I have a table as follows:
customers
custid credit amt month
001 C 2000 Jan-2012
001 D 5000 Feb-2012
001 C 3000 Mar-2012
001 C 3000 Apr-2012
001 D 7000 May-2012
I Have to write a single query to calculate the sum of credit and sum of debit value separately.Getting the sum sounds like a job for the SUM function.
Getting separate sums for credit and debit sounds like a job for GROUP BY.
Thanks & Regards,
SB2011Here's one way:
SELECT credit
, SUM (amt) AS total
FROM customers
GROUP BY credit
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
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 {message:id=9360002} -
Need a formula to calulate multiple cells and add the sum total to a cell in a other table
Im a chef and my monthly inventory is a time consuming task. I get invoices from multiple suppliers on each day of the week. I enter them into a spread sheet and then need to add the sum total for all the invoices for say MONDAY. That total needs to be entered into a cell in another table called "daily spend". Is there a formula to automatically add say all the invoices from monday and input the daily spend cell on that table. Here is an example
I created a column B-to give each day a number(sometimes multiple invoices come from the same supplier for each day)<GREEN>..If there was a way to do this differently...Im happy to change the layout of the spreadsheet. I want to add the total $ (column F) for each day together(all the blue fields) and then insert the total into another cell seen in the next table . So in this example its F4+F16+F17=?, ? inserted into N2 of the next table
Thanks so much"I ve finally has a play with the advice you gave me but I have realized that the formula you gave me is for a week....and like I mentioned in my reply to you, one table is weekly the other is monthly....is there a way to overcome this? (my answer to you explains it)"
Hi Gavin,
Unfortunately, the scale of your illustrations in that reply made them difficult (or impossible) to read, even on the Retina screen.
The first formula, used to fill column B, extracts the Weekday number for each date. Since these numbers should be equivalent to the day of the month, You'll need to replace this with a formula that returns the Day value of each date:
Old:
B2: =WEEKDAY(A,2)
New:
B2: =DAY(A)
Fill down to end of column.
Because of the arrangeent of your Data table, you will need to repeat this formula in column H (with references to column G), etc. for each set of dates in the table.
The SUMIF formula in column F is fine as is, except that it assumes all condition data will be in column B of Data, and all data to be summed will be in column F of Data. Since this is obviously not the case for your Data table, you will need a separate iteration of the formula for each week in the table, with the four SUMIF statements enclosed in a SUM statement:
E2: =SUM(SUMIF(Data :: $B,A2,Data :: $F),SUMIF(Data :: $H,A2,Data :: $L),SUMIF(Data :: $N,A2,Data :: $R),SUMIF(Data :: $T,A2,Data :: $X))
Fill down for as many rows as there are days in the month being summarized.
Column references in the formula assume that six columns are used for each week, and that there is no gap in the table between weeks.
Note that the formula does not distinguish between transactions on July 7 and those on June 7 or August 7. Because of this, the Data table must be limited to transactions in a single calendar month.
Regards,
Barry -
Suppressing a line if the sum of a value = 0 in a group footer
How do i suppress a line if the sum of a value = 0 in a group footer
I have tried this this formula in the section expert - Sum ({RM_INV.QUANTITY}) = 0
will not work.Hi Dana,
The sum function needs to include the group you have your total in like:
Sum ({table.FIELD1}, {RM_INV.QUANTITY}) = 0
{table.FIELD1} would be the field you are grouping on. Your formula was summing the grand total for RM_INV.QUANTITY.
Thanks,
Brian -
There is an error in the sum total displayed in infoty type 8.
Hi,
In infotype 8 there is an error in the sum total . Recently few wage types were added in the system.
Now the total amount of all the wagetypes is not displayed correct.
please tell me is there any functional aspect through which it can be corrected.2BAS Basic Salary 30.964,00 INR
2HRA House Rent Allowance 15.482,00 INR
2SPL Special Allowance 871,00 INR
1LTA Leave Travel All. (CTC) 2.580,00 INR
1DRI Driver's Pay Reimb. (CTC) 6.000,00 INR
1MED Medical Reimb. (CTC) 1.250,00 INR
1PET Petrol Reimb. (CTC) 4.000,00 INR
1GRA Gratuity (CTC) 1.489,00 INR
1LEN Leave Encashment (CTC) 300,00 INR
1BON Bonus(CTC) 6.881,00 INR
1IMC Medical Insurance (CTC) 179,00 INR
IV 24.10.2008 - 31.12.9999 * 47.317,00 INR*
Here the total amount for all the wage types is incorrect. This is my problem. How to correct the displayed total amount. -
How to get the sum total of just one row in the dashboard
How do I get the sum total of one row in the compound layer results. This is 11g
Does anyone know?
may be sales, I need the total at the bottom of the row..
thx
ChuckI fnd the answer,
in the table view, click edit then nxt to the columns and measures there is total sum icon. Click that, and choose after -
Sum the Sum total values above
Post Author: John Patterson
CA Forum: Formula
I have created a report that contains a list of values (in a group) that come from a formlar that has Sum {} totals in it. All I want to do is sum that list into one value below, just like Excel would do!
Crystal won't allow me to sum the results of group sum totals higher up the report. I have been told that I need to create a conditional running total or a set a variable to store the values required.
Any ideas?
Many thanks
JohnPost Author: fusion
CA Forum: Formula
Definitely Jami,I found out that Running Total is an answer. I still need to find out how to get a percentage of the total using a running total. When you use a summary option then there is a option that allows you to have the filed as a % of the total of that filed. How can you do the same using running total. I am trying to work with formulas but no any luck so far.Your help is highly appreciated -
Overall Result Row is not the Sum of Individual Values!
I am frustrated with a weird problem. I have an expense report in which Expense1 is shown a value of 8,126. If I drilldown by company code, the sum of the company codes is 8,235, but the "Overall Result" row is showing 8,126.
I tried drilling down by GL accounts, cost centers, profit centers, material and even currency. For all of these drilldowns the "Overall Result" row is 8,126 but the individual values sum out to be 8,235.
First I thought it could be "Zero Suppression" that is hiding some values from the display. But "Zero Suppression" was not active at all. I have checked the LISTCUBE and saw that the Expense1 should be 8,235 and not 8,126. The key figure properties "Calculate Result As" and "Calculate Single Values As" are set to "Nothing Defined" and "Use Default Direction". But still for some strange reason, the "Overall Result" row is different than the sum of individual rows. It's driving me crazy as I have ran out of ideas to figure out what's happening. Could someone help me with this? I would appreciate any input with points!Hi,
Remove the 'Suppress Zero rows/columns' from the query definition and then check the values.
Column A might have value, but for the same row column B might have zero, hence the row was not shown in the result set, but the overall result will include all such values as well, even thought it was not shown in the result set.
HTH,
regards,
Nataraj. -
Problem in SAP Query will displaing the curency and quentity values
Hi Gurus,
I had copied one query which is having currency and quantity values and displaying with out unit of measurement, And in my copied query i and able to see unit of measure automatically while executing the query.How to remove this .
Thanks and regards
Ravinder Elagamsolved by myself
-
Query to grab the sum and the most recent values?
hi,
Just wondering if its possible to have a query on the temp table,
which fetches school,most_recent(sub1),sum(sub2),sum(sub3) group by school
table temp
SCHOOL DATE1 SUB1 SUB2 SUB3
ABC 01-AUG-07 1 5 6
ABC 02-AUG-07 2 5 6
ABC 03-AUG-07 3 5 6
ABC 04-AUG-07 4 5 6
ABC 05-AUG-07 5 5 6
XYZ 01-AUG-07 6 7 8
XYZ 02-AUG-07 7 7 8
XYZ 03-AUG-07 8 7 8
XYZ 04-AUG-07 9 7 8
XYZ 05-AUG-07 10 7 8
Just wondering if its possible to have a query on the temp table,
which fetches school,most_recent(sub1),sum(sub2),sum(sub3)
required output
SCHOOL SUB1 SUB2 SUB3
ABC 5 25 30
XYZ 10 35 40
thanksI think you want this:
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-12-1981 950 30
7902 FORD ANALYST 7566 03-12-1981 3000 20
7934 MILLER CLERK 7782 23-01-1982 1300 10
7876 ADAMS CLERK 7788 12-01-1983 1100 20
4 rows selected.
real: 63
SQL>select * from emp order by deptno;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-06-1981 2450 10
7839 KING PRESIDENT 17-11-1981 5000 10
7934 MILLER CLERK 7782 23-01-1982 1300 10
7369 SMITH CLERK 7902 17-12-1980 800 20
7876 ADAMS CLERK 7788 12-01-1983 1100 20
7902 FORD ANALYST 7566 03-12-1981 3000 20
7788 SCOTT ANALYST 7566 09-12-1982 3000 20
7566 JONES MANAGER 7839 02-04-1981 2975 20
7499 ALLEN SALESMAN 7698 20-02-1981 1600 300 30
7698 BLAKE MANAGER 7839 01-05-1981 2850 30
7654 MARTIN SALESMAN 7698 28-09-1981 1250 1400 30
7900 JAMES CLERK 7698 03-12-1981 950 30
7844 TURNER SALESMAN 7698 08-09-1981 1500 0 30
7521 WARD SALESMAN 7698 22-02-1981 1250 500 30
14 rows selected.
real: 141
SQL>select * from emp a
2 where a.hiredate in (select max(b.hiredate)
3 from emp b
4 group by b.deptno
5 );
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-12-1981 950 30
7902 FORD ANALYST 7566 03-12-1981 3000 20
7934 MILLER CLERK 7782 23-01-1982 1300 10
7876 ADAMS CLERK 7788 12-01-1983 1100 20
4 rows selected.HTH
Ghulam -
Query to see the original Total Freight in a Sales Order
I need a query (for a approval procedure) to see the total freight charges (ORDR.TotalExpns) of a sales quotation. In what table does SBO saves the History of the Sales Order document ?
It is ADOC with ObjType = '17'
Thanks,
Gordon -
I need to change the sum of a column's total with javascript.
Hi,
The HTML output of a SUM column is as follows:
<td align="center" headers="COST" class="t2data"><b> 827.49</b></td>
I need to change the sum total with javascript.
The initial loading of the page SUMs the DB values correctly. Then onchange JS for a couple of factors may change one items COST.
When that one item's COST changes I need to reSUM the total with JS.
I was trying the following.. I don't know JS to well.
var tds = document.getElementsByTagName('td');
for (var xtd in tds) {
//alert('Here:'+xtd.headers);
if (xtd.headers=="COST") {
// you found the element, do what you need
alert(xtd.innerHTML);
After inserting the above code into my javascript is popups up
my alert, "Here:undefined"
and never hits the alert(xtd.innerHTML);Hi Ya'll,
I got the following working. See any problems?
headers=="COST" actually showed up in each row of the whole column, including the SUM. So it ended up being great so I could sum it in the JS.
I had to change the column type to NUMBER from VARCHAR2 for the initial SUM to work, so adding any formating to the SQL was not good. It looks pretty much what Andy has though... I found a slight hesitation it it though.. I have to work out a bug that prints the old total instead of the first.
var ltotal =0;
var tds = document.getElementsByTagName('td');
for (var k=0; k<tds.length; k++) {
if (tds[k].headers=="COST") {
var inputObjs= tds[k].getElementsByTagName('input');
if(inputObjs.length>0) {
for (var j=0;j<inputObjs.length;j++) {
ltotal+= parseFloat(inputObjs[j].value);
//alert(inputObjs[j].value);
//alert(ltotal);
}else{
tds[k].innerHTML=ltotal;
Message was edited by:
changed i to k to avoid the italics
Bill Carlisle -
Hi,
I am using Project Server 2010. I have a project schedule that has been baselined and no actual work has been charged to it. The project has 3 resources. I am in the Resource Usage View. With 2 of the three resources, the hours in the Baseline Work Column
on the left side of the view do not equal the sum total of weekly hours in the Timephased Grid. For instance, for resource JB the Baseline Work hours column says 1,392. When I total his weekly hours in the timephased grid I get 1368 hours; a variance
of 24. Resource RS has 794.5 hours in the Baseline Work column but the sum total of his weekly timephased grid hours is 710.5, a variance of 84 hours. In both cases, the sum of the hours in the timephased grid is less than the hours in the Baseline Work column.
What would be causing this? (I am cutting and pasting the weekly hours in the timephased grid into Excel and using the Excel sum function total). Is there a better timephased view I should be looking at to try to find the "missing
hours"? I have seen this before in project and it really has me stumped. Thanks.
Judy WashingtonHi Judy,
I could not reproduce your issue. Is your Project Server patched with the latest SP and CU?
Also can you reproduce this unexpected behavior with another project?
Can you split your screen from the resource usage view, display the resource form and click right on the grey part selecting "schedule"? Then you'll have the scheduled start and finish dates for the resource's assignments. This is to be sure that
you are not missing any parts of the assignments due to a wrong zoom in the timephased grid.
Hope this helps,
Guillaume Rouyre, MBA, MCP, MCTS | -
JTable get Old Value in the Listener of change Value
Software
JDK 1.5 Update 6
Requirements
I have a JTable I want to show the sum total of certain Cell Value.So I have added a TableModelListener by which on updating the cell Value I change the total in the JTextField. The Problem is If I change the value then I have to get the previous value that the cell had. How to get that original value before the update.
There is a way by which we can get the same by inserting one dummy column which stores previous value.But this method inserts unneccessary if you require the total of 3 columns and if you require the same thing again and again in different frames
Is There any way by which we can show the total
Thanks in advance
CSJakhariaCan I maintain a sum of a column in a JTextField such that I change the sum as soon as any value in that column is changed without recalculating the totalYes, now I understand the question you just want to update the total with the difference between the old value and the new value.
I don't see why you are going to all this trouble. Why complicate your program, just loop though all the values in each column and add them together. You will not have a performance problem. Here is a similiar example of this approach:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=566133
However, if you still don't like that solution then you can try overriding the getCellEditor(...) or prepareEditor(...) methods of JTable. These methods should be invoked when you start editing the cell and you could query the TableModel and save the current value. -
Total release values in GOA and ECC contract
Hi All
Contract query
i just want to match both ECC and GOA release values .
What is the table Total release value stored in SRM and ECC other than EKAB (Item release table)
i want total release value in both system so that i can compare very easily.
appreciate your help.
br
muthuIn SRM, the total release value is at header level in table BBP_PDHGP / VAL_PO_E. However, we have experienced occasional situation where this value on header differs from the sum on each item (BBP_PDIGP / VAL_PO_E). SAP wasn't able to offer more explanation than recommending that we write an custom report to synchronize them manually.
Maybe you are looking for
-
Update on BIOS & MEMORY problems? also DOT, PAT, settings...
Okie dokie, I'm new here, and I've been pouring through threads for the past 2-3 hours and doing searches, so please excuse these questions if they seem to have already been answered, but I would like to just ask a few (hopefully susinct) questions t
-
I googled and downloaded a free version in my mac but halfway of it being downloaded, I was informed it cannot be properly installed as it is running in my program? Is there a built in Word for Mac. I have never been a Mac user so everything is new t
-
Report needed: Absences x Quotas
Dear all, I need a report to show from wich quota was an absence used. Example: ABSENCE HOURS QUOTA DATE.. XX nn YY XX mm YY I know how to see it by using tables (PTQUODED) but I need a report for users, and be
-
I'd appreciate any help setting up my SPA 2102 w/ my D_Link wireless DIR 601
hello all Not sure if this has been addressed before... i found this link but my setup is slightly different. http://forums.linksysbycisco.com/linksys/board/message?message.uid=227491&comm_cc=US&comm_lang=en presently, I have a dry loop phone lin
-
How to increase instance size in oracle bpm 10.3.1
Hi, anyone please help me how to change instance size in oracle bpm 10.3.1 whenver i amm attaching maximum size file it is giving error Caused by: fuego.server.exception.MaxInstanceSizeRuntimeException: Max instance size exceeded. Current size is 690