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
Similar Messages
-
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? -
I need help figuring out how to take data from internet pages and enter it into one single row in an excel, or numbers if that is the easier way to go. I was also told access might be good to use. Basically I am going to chamber of commerce page and wanting to extract the member listing and enter in a database in a single line. The data is in different numbers of lines as you will see below (info edited to take out personal info). So I want to take the name of business, business owner, address, city, state, zip, and phone and put it into one line on a spreadsheet. I want to do this many times over. I think there is a way to do it through apple script and automator, but I have not been successful after 2 weeks of trying and searching. I have over 800 listings and I surely don't want to go through and do them one at a time. Any suggestions?
Data from website:
Westrock Coffee
Mr.
Collins Industrial Place
North Little Rock, AR 72113
Phone:
Send Email
Member Since: 2011
Sweet Creations by DJ
Ms. J
allace Bridge Road
Perryville, AR 72126
Phone:
Fax:
Send Email
Member Since: 2013
See Also Woman Owned and/or CEO
Premium Refreshment Service
Mr. E
est Bethany Road
North , AR 72117
I want it to look like this
Company name, owner name, address, city, state, zip, phone
How can I get the extra data out of the way and remove the format so that it will go into excel? Thanks for any help you can provide. I am not to savvy with code, but I got a friend who is an IT guy that can help. Thanks againSo, basically, create 800 individual entries, each one containing everything from business name through the phone (not fax) number, add some commas and spaces to entries, and then put each entry on a separate line?
1. Go to website page such as this one-- http://www.littlerockchamber.com/CWT/External/WCPages/WCDirectory/Directory.aspx ?ACTION=newmembers --which seems formatwise very close to what you're trying to scrape.
2. Cmd-A to select all. Cmd-C to copy it to clipboard.
3. Open freeware TextWrangler. Cmd-V to paste info from clipboard into a blank TW document.
4. Remove lines from top and bottom so that only membership list remains.
5. Process lines to remove everything from "Fax" line through "See Also" line. Only business name through phone number will remain in the file.
--A. TW > Text > Process Lines containing . . .
-----(check "Delete matched lines"; uncheck all others)
-----Enter "Send Email" in the search box.
-----Click Process.
--B. Repeat 5A for other lines to be removed
------Member Since
------See Also
------Fax
6. Insert markers to separate entries:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r\r\r\r
------in replace box: \r***
------Click Replace All
7. Remove remaining blank lines:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r\r
------in replace box: \r
------Click Replace All
8. Add comma and space at end of each line:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: $
------in replace box: , (comma space)
------Click Replace All
9. Remove all returns:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \r
------in replace box: (leave blank)
------Click Replace All
10. Insert returns in place of markers:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: \*\*\*, (backslash asterisk backslash asterisk backslash asterisk comma space)
------in replace box: \r
------Click Replace All
11. Remove trailing comma and blank on each line:
TW: Search > Find . . .
------(check "Wrap around" and "Grep")
------in Find box: , $ (comma space dollar sign)
------in replace box: (leave blank)
------Click Replace All
Import this text file into Excel or Numbers. -
hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
i do not have a mac home pc. just a regular pcI had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do: Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version! One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck
-
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 calculate the sum of cyclomatic complexity of all methods?
I can write a rule to calculate the sum of cyclomatic complexity of all methods in my system?
Hi Dileep,
In your query you are not specified whether the SUM of entire internal table SALARY or break up SALARY.
If you want just the SUM of the entire internal table SALARY.
Try this code.
begin of itab occurs 0,
name(10),
salary type i,
end of itab.
itab-name = 'ABC'. itab-salary = 25000.
append itab.
itab-name = 'CDF'. itab-salary = 50000.
append itab.
itab-name = 'FGH'. itab-salary = 30000.
append itab.
itab-name = 'LMN'. itab-salary = 35000.
append itab.
itab-name = 'QPR'. itab-salary = 40000.
append itab.
loop at itab.
at last. " Note the control statement used here
sum.
write: 'The total salary is',itab-salary.
endat.
endloop.
Regards,
Smart -
How to calculate the area of a large number of polygons in a single query
Hi forum
Is it possible to calculate the area of a large number of polygons in a single query using a combination of SDO_AGGR_UNION and SDO_AREA? So far, I have tried doing something similar to this:
select sdo_geom.sdo_area((
select sdo_aggr_union ( sdoaggrtype(mg.geoloc, 0.005))
from mapv_gravsted_00182 mg
where mg.dblink = 521 or mg.dblink = 94 or mg.dblink = 38 <many many more....>),
0.0005) calc_area from dualThe table MAPV_GRAVSTED_00182 contains 2 fields - geoloc (SDO_GEOMETRY) and dblink (Id field) needed for querying specific polygons.
As far as I can see, I need to first somehow get a single SDO_GEOMETRY object and use this as input for the SDO_AREA function. But I'm not 100% sure, that I'm doing this the right way. This query is very inefficient, and sometimes fails with strange errors like "No more data to read from socket" when executed from SQL Developer. I even tried with the latest JDBC driver from Oracle without much difference.
Would a better approach be to write some kind of stored procedure, that adds up all the single geometries by adding each call to SDO_AREA on each single geometry object - or what is the best approach?
Any advice would be appreciated.
Thanks in advance,
JacobHi
I am now trying to update all my spatial table with SRID's. To do this, I try to drop the spatial index first to recreate it after the update. But for a lot of tables I can't drop the spatial index. Whenever I try to DROP INDEX <spatial index name>, I get this error - anyone know what this means?
Thanks,
Jacob
Error starting at line 2 in command:
drop index BSSYS.STIER_00182_SX
Error report:
SQL Error: ORA-29856: error occurred in the execution of ODCIINDEXDROP routine
ORA-13249: Error in Spatial index: cannot drop sequence BSSYS.MDRS_1424B$
ORA-13249: Stmt-Execute Failure: DROP SEQUENCE BSSYS.MDRS_1424B$
ORA-29400: data cartridge error
ORA-02289: sequence does not exist
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 27
29856. 00000 - "error occurred in the execution of ODCIINDEXDROP routine"
*Cause: Failed to successfully execute the ODCIIndexDrop routine.
*Action: Check to see if the routine has been coded correctly.
Edit - just found the answer for this in MetaLink note 241003.1. Apparently there is some internal problem when dropping spatial indexes, some objects gets dropped that shouldn't be. Solution is to manually create the sequence it complains it can't drop, then it works... Weird error. -
How to calculate the sum of the values of some columns of a table
hi
i want to get in the column averages just the average of the values of some columns not all the columns of the table.what i have to change exactly in this block diagram.even if the size of the table is 25,i want the division to be the number of values in each column(= number of rows)
just like that:
Solved!
Go to Solution.
Attachments:
operations on some columns.vi 10 KBi did exactely what u told me, i think i missed something because i don't get the average value of the rows i want
Attachments:
average.vi 11 KB -
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 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 helpok, 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 -
Read a file, calculate the momentum of two columns and calc a summation of them
I have a file which das three columns. The first of them isn't important for this problem. I have to read the second and the thid ones, and then mutiply them (to calculate the momentum), if they are at the same line. After that I need to sum all the results that I calculated.
How can I do this?If all the data in the file are numeric values you can use the Read From Spreedsheet File VI to get the 2-D array of data. Then use the index array function and index out column 1 and 2. Then multiple the arrays together, and then there is a Sum array elements VI that should finish it off.
See the attached image
Attachments:
Temp.JPG 19 KB -
How to display the rows in to columns and columns into rows?
DES:- I know by using pivot and unpivot you can convert rows into columns and columns into rows but i don't know how to write the syntax?
Hi,
Besides the places Martin mentioned above, there are many examples in the forum FAQ:
https://community.oracle.com/message/9362005#9362005
For an example of both PIVOT and UNPIVOT in the same query, see
http://forums.oracle.com/forums/thread.jspa?threadID=920854&tstart=0 -
Including both the Jquery script to calculate the total of calculated column and freeze header row
Hi
I managed to get this code from here,
http://techtrainingnotes.blogspot.in/2013/03/freezing-title-row-of-sharepoint-2010.html done on the page
I also managed to get this code from here, http://www.sharepointed.com/2012/11/28/jquery-total-calculated-column-in-sharpoint-2010/ done on another page.
However, I need this to be done on the same page. When I do this, I only get the freeze header thingy to be up and not the calculated column. Could something be blocking.Hi,
You take the code below for a try in your environment after modified it a bit to suit the structure of your page:
<script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
// update the list after the page has loaded
_spBodyOnLoadFunctionNames.push("TTNListScroll");
function TTNListScroll()
// Scrolling list code from TechTrainingNotes.blogspot.com
// Edit the next line with your list's summary name
var SummaryName = "List28_frozenheader ";
var TTNmyTable;
var TTNListDiv = document.createElement('div');
var TTNHeadingDiv = document.createElement('div');
var tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++)
if(tables[i].summary == SummaryName)
TTNmyTable = tables[i];
break;
if(TTNmyTable == undefined)
// // Table not found!
// you may want to comment out the next line after testing
alert("table '" + SummaryName + "' not found");
return;
// make a copy of the table for the heading area
TTNHeadingDiv.appendChild(TTNmyTable.cloneNode(true));
TTNHeadingDiv.id="TTNheading";
TTNListDiv.appendChild(TTNmyTable.cloneNode(true));
TTNListDiv.id="TTNlist";
TTNListDiv.width="100%";
// udpate the page
var TTNnode = TTNmyTable.parentNode;
TTNnode.replaceChild(TTNHeadingDiv, TTNmyTable);
TTNnode.appendChild(TTNListDiv);
// hide the heading row of the main list
TTNListDiv.childNodes[0].rows[0].style.visibility='hidden';
// make the DIV for the heading the same width as the main list
TTNHeadingDiv.childNodes[0].style.width = TTNListDiv.childNodes[0].offsetWidth;
getSum(3);
//pass the column number to this function
function getSum(col)
var m = "$"; //change to "" for non-money format
var arrayList = $("table.ms-listviewtable:first> tbody> tr:gt(0)").find(">td:eq("+col+")");
var x = 0;
var p1 = "";
var p2 = "";
$.each(arrayList, function(){
//console.log('$(this).text(): '+$(this).text());
x += Number($(this).text().replace(/\$|,|\)/g, "").replace(/\(/g,"-"));
//console.log('x: '+x);
//format for negative numbers
if (x < 0)
p1 = "(";
p2 = ")";
x = Math.abs(x);
$('#diidSortcal').attr('visibility','visible');
$('#diidSortcal').text($('#diidSortcal').text()+'(sum: '+x+')');
function addCommas(nStr)
//formats number
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1))
x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
</script>
<style type="text/css">
#TTNheading
height:28px;
#TTNlist
height:200px;
overflow-y:scroll !important;
overflow-x:auto
</style>
Then you might get something like this:
Feel free to reply if there are still any questions.
Best regards
Patrick Liang
TechNet Community Support -
How to calculate the maximum session for Confernecing and Xcoder on VG
Hi All
Please help me to understand the logic and concept that how we can calculate the number of session that we can define for the Conferencing and Xcoder Configuration on the VG.
Regards
ChamanHi Jaime
Thanks for Reply.
I created the Dsp profile . According to ISR i configured the Sessions . But i want to know the exact concept how to calcluate and if suppose i want some modification in future according to the conference calls that i want to support how do i calculate??
dspfarm profile 2 transcode
codec g729abr8
codec g729ar8
codec g711alaw
codec g711ulaw
codec g729r8
codec g722-64
maximum sessions 13
associate application SCCP
dspfarm profile 1 conference
codec g729br8
codec g729r8
codec g729abr8
codec g729ar8
codec g711alaw
--More-- codec g711ulaw
maximum conference-participants 16
maximum sessions 3
associate application SCCP -
How to calculate when I need multiple WFE and APP servers in SharePoint 2013 ?
Hi,
Please let me know about those factors are involved on the above topic. Share something from the real experience or with examples in details.
Thanks
srabonHi,
NOte: some links although for 2010 but fits for 2013
for the WFE is the RPS Requests per second versus the users
to get the RPS
http://smallcitydesign.com/how-to-get-sharepoint-2010-requests-per-second-rps/
and this excel sheet to get the users versus RPS
http://pcfromdc.blogspot.com/2013/02/determine-max-users-from-requests-per.html
and here you are how to get the number of front ends
http://abhayajoshi.blogspot.com/2014/01/how-to-calculate-number-of-web-front_24.html
for Apps server, it is based on memory and cpu consumption, check those links
http://blogs.msdn.com/b/sanjaynarang/archive/2013/04/06/sizing-and-capacity-planning-for-sharepoint-2013-resources.aspx
https://technet.microsoft.com/en-us/library/ff758645.aspx
https://technet.microsoft.com/en-us/library/cc262971.aspx
the most important thing after you do you initial capacity planning is capacity mangement, check my wiki article in here
http://social.technet.microsoft.com/wiki/contents/articles/28226.sharepoint-2013-capacity-management.aspx
you can also make load testing using the following:
Visual studio or
https://gallery.technet.microsoft.com/office/PressurePoint-Dragon-for-58648ae4
Kind Regards,
John Naguib
Senior Consultant
John Naguib Blog
John Naguib Twitter
Please remember to mark this as answered if it helped you
Maybe you are looking for
-
Sqlplus crash when connecting to 7.3.2
I know I'm missing something stupid here. sqlplus completely dumps when I put in a connect string to a 7.3.2 database. I know the descriptor is right, and I can tnsping it fine. I bet its an env-var or something........ Any help is appreciated. thanx
-
I really like the cover flow view but it seems the albums are keyed on Artist so if different tracks have different artists, they show up as multiple albums in the cover flow view. Is there any way to make it key on Album name instead? iMac 20" Core
-
Fcp - color - fcp ALL BLURRY in PAL Anamorphic - any ideas?
ok, so admittedly i'm not working on my normal system but i've been using color (and final touch before that) for a while on a number of small and large fcp projects (dv, hdv, prores) and now i'm working on a small tv show for austrian broadcasting.
-
I am sorry a am i newbie in dhcp. I have a v490 server ,with 4g memory,the server is to be configured as a dhcp server.And i add subnets to the server ,and then distribute IPs for each subnet. The are about 50 subnets and 8000 IPs in each subnet,but
-
I use a 15" laptop which display area is inefficiently used by the too popular HTML5/CSS blobs and huge typefaces, I imagine to appeal to tiny phone screens. How can I take back control of my display?