How to get the total of a column in php
I have a php MySQL database that stores the bills paid, I need to show all of the column that stores the individual payments
what I have so far
$colname_rsProperty = "-1";
If (isset($_GET['recordID'])) {}
$colname_rsProperty = $_GET ["recordID"];
}
@mysql_select_db ($database_hostprop, $hostprop);
$query_rsProperty = sprintf ("" SELECT * FROM host_editprop, host_editpropUtil, host_editpropUtilComp WHERE host_editprop.prop_id = AND host_editpropUtil.prop_id = host_editprop.prop_id AND host_editpropUtilComp.utilID = host_editpropUtil.UtilPropNameID %s ", GetSQLValueString ($colname_rsProperty,"text")");
$query_limit_rsProperty = sprintf ("%s LIMIT %d, %d", $query_rsProperty, $startRow_rsProperty, $maxRows_rsProperty);
$rsProperty = mysql_query ($query_limit_rsProperty, $hostprop) or die (mysql_error ());
$total = 0;
$total += $row_rsProperty ["utilityAmount"];
the host_editpropUtil column is called utilityAmount
and the individual amounts are the echoes of
<? PHP echo DoFormatCurrency ($row_rsProperty ['utilityAmount'], 2, ','.', ' £');? >
and I want to put the total at the end of these
and just an echo of the total need
<? PHP echo $total? >
This is just to show the first value in the table
Thanks in advance
got it to work
$colname_rsProperty = "-1";
If (isset($_GET['recordID'])) {}
$colname_rsProperty = $_GET ["recordID"];
}
@mysql_select_db ($database_hostprop, $hostprop);
$query_rsProperty = sprintf ("" SELECT * FROM host_editprop, host_editpropUtil, host_editpropUtilComp WHERE host_editprop.prop_id = AND host_editpropUtil.prop_id = host_editprop.prop_id AND host_editpropUtilComp.utilID = host_editpropUtil.UtilPropNameID %s ", GetSQLValueString ($colname_rsProperty,"text")");
$rsProperty = mysql_query ($query_rsProperty, $hostprop) or die (mysql_error ());
$row_rsProperty = mysql_fetch_assoc ($rsProperty);
$totalRows_rsProperty = mysql_num_rows ($rsProperty);
@mysql_select_db ($database_hostprop, $hostprop);
$query_rsSum = sprintf ("SELECT host_editpropUtil.utilityAmount, host_editprop.prop_id, host_editprop, host_editpropUtil.prop_id FROM host_editpropUtil WHERE host_editpropUtil.prop_id = host_editprop.prop_id AND host_editprop.prop_id = %s", GetSQLValueString ($colname_rsProperty, "text") ");
$rsSum = mysql_query ($query_rsSum, $hostprop) or die (mysql_error ());
$totalRows_rsSum = mysql_num_rows ($rsSum);
$grandTotal = 0;
Use a loop here
{If ($row_rsSum = mysql_fetch_assoc ($rsSum))
$grandTotal += $row_rsSum ["utilityAmount"];
$row ['utilityAmount'] ;// and view the contents of the line
$row ['SUM (utilityAmount)'; / / and display the contents of the line
}
Tags: Dreamweaver
Similar Questions
-
How to get the value of a column in sql query?
Hi, anyone knows how to get the value of a column in sql query?
Here is my code, the value must be 1350079224397 in my PB, but I get 0
QString query ("SELECT version FROM db_version");
QVariant result = sda.execute (query);
QVariantMap versionMap = result.toList () such () .toMap ();
If (! versionMap.IsEmpty ())
{
qDebug()<"Version: "="">"Version:><>
}OK, I have the solution
QString query ("SELECT version as version FROM db_version");
-
How to get the total number of pages
Is there anyone know how to get the total page after generate us the pdf file. I use the remainder method and create an external process. ?
In the workbench, I use a SetValue
Until you assemble the document that you need to build the DDX string and specify the xml information.
Concat (/process_data/@ddxHeadStr, "
AFTER mounting
Use SetValue that set your xmlinfo variable (xml type)
xmlInfo/process_data/game FOR
/ process_data/assemblerResult/Object/documents[@id]
[ ='doc_info.xml']
Then get your pages from the XMLinfo
=
/ process_data/xmlInfo/docinfo/NUMPAGES
I hope this helps. Send an e-mail if it is not explicit. I had to fight over there recently and feel that the documentation really lacks.
-
How to query the total number of columns and lines filled with data?
How to get the number of rows and columns in Exel file data using Excel report?
Since you have posted this question in the forum of LabWindows/CVI, I guess you want to know how to do with CVI.
You need to know how to open and activate the Excel data file.
Depending on the function returns the total number of columns and lines col_count row_count, respectively.
-----------------------------------------------------------------------------------------------------------------------------------------
int CountColumnsAndRows (void)
{
Error HRESULT = 0;
CAObjHandle rangeCurrentRegionHandle = 0;
CAObjHandle rangeColumnsHandle = 0;
CAObjHandle rangeRowsHandle = 0;
unsigned long col_count = 0, row_count = 0;
Must use the 'A1' property and CruuentRegion count the total of columns and lines, including the drafts!
error = CA_VariantSetCString (& MyCellRangeV, 'A1');
error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, & ExcelRangeHandle);
If (error<0) goto="">0)>
error = Excel_GetProperty (ExcelRangeHandle, & ErrorInfo, Excel_RangeCurrentRegion, CAVT_OBJHANDLE, & rangeCurrentRegionHandle);
If (error<0) goto="" error="">0) >
error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeColumns, CAVT_OBJHANDLE, & rangeColumnsHandle);
If (error<0) goto="" error="">0) >
error = Excel_GetProperty (rangeColumnsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & col_count);
If (error<0) goto="">0)>
error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeRows, CAVT_OBJHANDLE, & rangeRowsHandle);
If (error<0) goto="" error="">0) >
error = Excel_GetProperty (rangeRowsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & row_count);
If (error<0) goto="">0)>Error:
CA_VariantClear (& MyCellRangeV);
CA_VariantClear (& MyVariant);
ClearObjHandle (& ExcelRangeHandle);
ClearObjHandle (& rangeCurrentRegionHandle);
ClearObjHandle (& rangeColumnsHandle);
ClearObjHandle (& rangeRowsHandle);
If (error<>
ReportAppAutomationError (error);
error return;
} -
Is it possible to get the total value of column and set to another area
Hello
Is it possible to get the total value of a particular column, and assign this value to another discipline?
How to do this?
Thanks in advance,
SANHi SAM,
If your controller class throw this message it means that it works very well. Follow these steps, I hope this will solve your problem.
1 check the following
OAApplicationModule am = pageContext.getApplicationModule (webBean);
OAViewObject ratvo = (OAViewObject) am.findViewObject("*CompetenceElementsVO*"); It should be the name of the instance instead of the name Physics vo vo.
OAViewObject valuevo = (OAViewObject) am.findViewObject("*PerRatingLevelsVO*");2. extend this controller class that is associated with this region.
I hope it will work now.
Haroon.
-
How to get the total of the multiple products of cells
I want to save my money on the balances of the hand for different days of the year and see if I can develop a trend and reduce my expenses. I can easily make a cell inside of my table that tells me how many I have a kind of money (20 of 5 cents, 9 $2, 3 50 $, etc.) for today (aid = Lookup), the day where I'm looking for my document. This can be used to show me a trend, however, if I want to do another column that keeps track of this total, so that I can use it as a reference to a line chart elsewhere.
My problem is that when I want to many the last row of cells (filled with the types of currency) by their amounts (20, 9, 3), I have to do for each cell, and if I try to fill it, numbers changes the cells I want it multiply so that now the two amounts are multiplied, rather than the independent form and variable amount.
My question is: which formula can be used to multiply each B1, C1, D1 etc. with the appropriate..., C2, B2 or B3 and C3... etc, so that I can fill and then also for other cells in column N.
Hi Kasai,
SUMPRODUCT is your friend here.
The totals are in column N.
N2 and filled down: = IF (COUNT(B2:M2)<>SUMPRODUCT($B$1:$M$1,$B2:$M2))
The IF part removes the calculation of this row if no number has been involved in any of columns B to M.
If everything has been entered, the IF condition returns FALSE and the calculation of SUMPRODUCT (in "BOLD") is done.
I noticed that you included a piece of 20 cents in the list in the upper part, which has awakened my curiosity. Is this typo, or is it a country whose currency is denominated in "dollars" which is a coin circulating 20 cents worth?
Kind regards
Barry
-
How to get the total runtime of a file of tkprof
Hello
I have a file tkprof. How can I get the total execution time. Through the file I guess than the sum of "Total expected" would give the total time in the section "elapsed time are waiting on the following events:
. Sample tkprof is given below.
SQL ID: gg52tq1ajzy7t Plan Hash: 3406052038 SELECT POSTED_FLAG FROM AP_INVOICE_PAYMENTS WHERE CHECK_ID = :B1 UNION ALL SELECT POSTED_FLAG FROM AP_PAYMENT_HISTORY APH, AP_SYSTEM_PARAMETERS ASP WHERE CHECK_ID = :B1 AND NVL(APH.ORG_ID, -99) = NVL(ASP.ORG_ID, -99) AND (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'ALWAYS' OR (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'CLEARING ONLY' AND APH.TRANSACTION_TYPE IN ('PAYMENT CLEARING', 'PAYMENT UNCLEARING'))) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 442 0.08 0.13 0 0 0 0 Fetch 963 0.22 4.72 350 16955 0 521 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 1406 0.31 4.85 350 16955 0 521 Misses in library cache during parse: 1 Optimizer mode: ALL_ROWS Parsing user id: 173 (recursive depth: 1) Number of plan statistics captured: 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 UNION-ALL (cr=38 pr=3 pw=0 time=139 us) 1 1 1 TABLE ACCESS BY INDEX ROWID AP_INVOICE_PAYMENTS_ALL (cr=5 pr=0 pw=0 time=124 us cost=6 size=12 card=1) 1 1 1 INDEX RANGE SCAN AP_INVOICE_PAYMENTS_N2 (cr=4 pr=0 pw=0 time=92 us cost=3 size=0 card=70)(object id 27741) 0 0 0 NESTED LOOPS (cr=33 pr=3 pw=0 time=20897 us) 0 0 0 NESTED LOOPS (cr=33 pr=3 pw=0 time=20891 us cost=12 size=41 card=1) 1 1 1 TABLE ACCESS FULL AP_SYSTEM_PARAMETERS_ALL (cr=30 pr=0 pw=0 time=313 us cost=9 size=11 card=1) 0 0 0 INDEX RANGE SCAN AP_PAYMENT_HISTORY_N1 (cr=3 pr=3 pw=0 time=20568 us cost=2 size=0 card=1)(object id 27834) 0 0 0 TABLE ACCESS BY INDEX ROWID AP_PAYMENT_HISTORY_ALL (cr=0 pr=0 pw=0 time=0 us cost=3 size=30 card=1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 350 0.15 4.33 Disk file operations I/O 3 0.00 0.00 latch: shared pool 1 0.17 0.17 ********************************************************************************
user13019948 wrote:
HelloI have a tkprof file. How can I get the total execution time.
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 1406 0.31 4.85 350 16955 0 521TOTAL ELAPSED TIME is 4.85 seconds from line above
-
How to get the Total number of nodes XML?
Hi all
I have a Flash program that I do in Actionscript 3, using CS6.
I use the XMLSocket class to read XML data. I'll write some examples of XML that is sent to the Flash
program below...
I know with this line here (below) I can access the 4th 'element or node' of XML data.
To access the XML nodes/elements:
* I created a Variable XML, called xml, and "e.data" contains ALL the XML data
var XML = XML (e.data);Access to the 4th item of the data:
. xml MESSAGE[3].@VAR; -> 'loggedOutUsers '.
. xml MESSAGE[3].@TEXT; ---> "15"
EXAMPLE OF XML DATA:
< FRAME >
0 < VAR MESSAGE = "screen2Display" TEXT = "FRAME_1" / >
1 < VAR MESSAGE = "numUsers" TEXT = "27" / >
2 < VAR MESSAGE = "loggedInUsers" TEXT = "12" / >
3 < VAR MESSAGE = "loggedOutUsers" TEXT = "15" / >
4 < VAR MESSAGE = "admins" TEXT = "2" / >
< / FRAMEWORK >
I'm new to Flash and Actionscript but I am very familiar with other languages and how paintings and other work, and I know for
example, in a Shell Script to get the total number of items in an array called 'myArray' I wanted to write something like
This-> ${#myArray [@]}. And since the data processing XML looks a lot like a table I thought that there was perhaps
a way to access the total number of "nodes or elements" in the XML data...?
Any thoughts would be much appreciated!
Thanks in advance,
Matt
even if you don't need to run to the loop to know the length
var levelList: XMLList = xml.children ();
levelList.length (); This will give you the length of all children in your case of length MESSAGE of nodes;
Pls click useful if my answer is helpful.
Thank you
Bala
-
How to get the name constraintlist and column in a table?
Hello
can someone please tell me how to get the type of constraint, and it is imposed on the names of columns in a table.
Thank you
NicoHello
Use the two tables:
select * from all_constraints select * from ALL_CONS_COLUMNS
Sorry SY, you were faster than me...
Published by: user11268895 on August 19, 2010 13:27
-
How to get the total line count COUNT (*) SELECT and put on a page?
Hello
I use JDeveloper 10.1.3.4. I need get the total number of rows in a table and display it on a page and the problem in doing so. At the sqlplus prompt the row count simply would be, for example:
I wonder if having this simple number must be so complicated and if there is more simple, better ways. Here's how I do it and the problem encountered.select count(*) from BILL;
1. the name of the page to display the number is summary.jspx. It has a grain of support that "summed" as the managed bean name in faces - config.xml, and the name of the bean class is "summary." The component output on the page is:
2. in summary the bean code is:<h:outputText value="#{summary.totalStudentsCount}" binding="#{summary.outputText5}" id="outputText5"/>
The idea of calling a stored function usnig as a "helper" method is 25.5.3 in the Developer's guide, which is closest to you in my need. It's for the functions with the one IN argument; but in my case, the function is not any argument IN. That's why, when you call the helper method CallStoredFunction(), I gave an empty as the last argument and amazing array that caused the problem:private Number totalStudentsCount; public static int NUMBER = Types.NUMERIC; public void setTotalStudentsCount(Number totalStudentsCount) { this.totalStudentsCount = totalStudentsCount; } public Number getTotalStudentsCount() { ZBLCModuleImpl zblcam = getZBLCModuleImpl(); LoggedInStudentImpl studentTable = (LoggedInStudentImpl)zblcam.getLoggedInStudent(); String sql = "select count(lsap_uid) from BILL"; studentTable.setQuery(sql); return (Number)CallStoredFunction(NUMBER, "get_total_students(?)", new Object[] {}); } private ZBLCModuleImpl getZBLCModuleImpl() { FacesContext fc = FacesContext.getCurrentInstance(); ValueBinding vb = fc.getApplication().createValueBinding("#{data}"); BindingContext bc = (BindingContext)vb.getValue(fc); DCDataControl dc = bc.findDataControl("ZBLCModuleDataControl"); ApplicationModule am = (ApplicationModule)dc.getDataProvider(); return (ZBLCModuleImpl)am; } protected Object CallStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) { CallableStatement st = null; ZBLCModuleImpl zblcam = getZBLCModuleImpl(); try { st = zblcam.getDBTransaction().createCallableStatement("begin ? := " + stmt + "; end", 0); st.registerOutParameter(1, sqlReturnType); if (bindVars != null) { for (int z = 0; z < bindVars.length; z++) { st.setObject(z + 2, bindVars[z]); } } st.executeUpdate(); return st.getObject(1); } catch (SQLException e) { throw new JboException(e); } finally { if (st != null) { try { st.close(); } catch (SQLException e) { throw new JboException(e); } } } }
3. the registered function has been tested and works fine at the sqlplus prompt:return (Number)CallStoredFunction(NUMBER, "get_total_students(?)", new Object[] {});
4. when the summary.jspx page is run, the browser is full of error messages, the first long line is here (I have split several online for ease of reading):create or replace function get_total_students return NUMBER AS v_student_count NUMBER; BEGIN select count(ldap_uid) into v_student_count from bill; return v_student_count; END;
Thus,.javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Error getting property 'totalStudentsCount' from bean of type zblc.viewcontroller.backing.staff.Summary: oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.sql.SQLException, msg=Missing IN or OUT parameter at index:: 2
(1) what is the problem? What is this parameter IN or OUT of {color: red} index: 2 {color} consult? It has to do with the empty array as the last argument in the call to the helper method?
(2) this approach is an overdose, and are there more simple and better ways?
Thank you very much for help!
NewmanHello
Is there a specific reason why you don't simply create read only object to display with some count (*) as OFCASES from MYTABLE and then just drag and drop the attribute ofcases in page?
Kind regards
Branislav
-
How to get the total reserved cpu or total cpu capacity available with PowerCLI?
I am able to use the cmdlet Get-Host for a total capcity of CPU and the current CPU usage. However, I am not able to get the total of reserved CPU. I also tried another cmdlet like Get-VMHostAdvancedConfiguration, but which does not include either total reserved cpu info. Any suggestion?
OK, try this
foreach($esx in Get-VMHost){ $parent = Get-View $esx.ExtensionData.Parent $rp = Get-View $parent.ResourcePool Select -InputObject $esx -Property Name, @{N="Total CPU Capacity MHz";E={$rp.Runtime.Cpu.MaxUsage}}, @{N="Reserved CPU Capacity MHz";E={$rp.Runtime.Cpu.ReservationUsed}}, @{N="Available CPU Capacity MHz";E={$rp.Runtime.Cpu.MaxUsage - $rp.Runtime.Cpu.ReservationUsed}} }
-
How to get the total number of frames
Hai...
I need this code...
I have n number of files (swf) flash. Each file contains a number of images. I need to get the totalframes of this flash in Actionscript 3.0 files.
Please help me through Actionscript.
You can use a movieclip totalFrames property to get the total number of frames for a timeline.
-
How to get the total number of occurrences based on the value of a column.
Hi all
It is the first time I'll ask the question here on your forum, but since then followed several threads. I guess it's now my turn to ask a question. Anyway here's the thing, I have a query that should return to count the number of rows based on the value of HOUSING. Something like this:
-----
-----WIPDATAVALUE SLOT N M 1-2 TRALTEST43S1 1 3 1-2 TRALTEST43S1 2 3 3 TRALTEST43S1 3 3 4-6 TRALTEST43S2 1 4 4-6 TRALTEST43S2 2 4 4-6 TRALTEST43S2 3 4 7 TRALTEST43S2 4 4
As you can see above, on the TRALTEST43S1 of the SLOT, there are three occurrences, so M (Total number of occurrences) must be three and this column N he's counting. It is the same with the TRALTEST43S2 of the SLOT. It's the query I have so far:
And it leads to something like this:SELECT DISTINCT WIPDATAVALUE, SLOT , LEVEL AS n , m FROM ( SELECT WIPDATAVALUE , SLOT , (dulo - una) + 1 AS m FROM ( SELECT WIPDATAVALUE , SLOT , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, 1, INSTR(wipdatavalue, '-')-1) END AS una , CASE WHEN INSTR(wipdatavalue, '-') = 0 THEN wipdatavalue ELSE SUBSTR(wipdatavalue, INSTR(wipdatavalue, '-') + 1) END AS dulo FROM trprinting WHERE (containername = :lotID OR SLOT= :lotID) AND WIPDATAVALUE LIKE :wip ) ) CONNECT BY LEVEL <= m ORDER BY wipdatavalue;
-----
-----WIPDATAVALUE SLOT N M 1-2 TRALTEST43S1 1 2 1-2 TRALTEST43S1 2 2 3 TRALTEST43S1 1 1 4-6 TRALTEST43S2 1 3 4-6 TRALTEST43S2 2 3 4-6 TRALTEST43S2 3 3 7 TRALTEST43S2 1 1
I think that my current query based results M and N on WIPDATAVALUE and not HOUSING that's why I get the wrong result. I also tried to use WITH instruction and it works well, but unfortunately, our system cannot accept the subquery factoring.
I know that you guys will be of help because you are all awesome. Thank you all
Published by: 1001275 on April 19, 2013 20:07
Published by: 1001275 on April 19, 2013 20:18Hello
1001275 wrote:
Hi sb92075,You are right that it is available with this version. But our system doesn't put queries that use subquery factoring.
What system are you talking about? If you really have something that prevents you from using all the features of Oacle, you should seriously think about fixing it.
Any other ideas on how we can do this without help WITH clause?
Yes; If a WITH clause is referenced that once, it can be re-written as a point of view online:
SELECT wipdatavalue , slot , ROW_NUMBER () OVER ( PARTITION BY slot ORDER BY low_number ) AS m , COUNT (*) OVER ( PARTITION BY slot ) AS n FROM ( -- Begin in-line view (got_numbers) SELECT wipdatavalue , slot , TO_NUMBER ( SUBSTR ( wipdatavalue , 1 , INSTR ( wipdatavalue || '-' , '-' ) - 1 ) ) AS low_number , TO_NUMBER ( SUBSTR ( wipdatavalue , 1 + INSTR ( wipdatavalue , '-' ) ) ) AS high_number FROM trprinting ) -- End in-line view got_numbers CONNECT BY LEVEL <= high_number + 1 - low_number AND low_number = PRIOR low_number AND PRIOR SYS_GUID () IS NOT NULL ORDER BY low_number , m ;
-
How to get the total of column in javascript for an inputText.
Hi Experts,
Jdev 12.1.3.0
How can I make a total of a column in javascript. Scope is backingbeanscope.
column contains inputText and column footer is an outputText.
Thank you
Roy
Hi Roy, you have inputText, average, you add the line, then you want to calculate the total? If that's true, then you should try the JS code below
function doSum (evt) {var inputTxt = evt.getSource ();} var num = 0; var colId = inputTxt.getProperty ("colId"); outId var = inputTxt.getProperty ('outId'); var table = inputTxt.findComponent('::t1'); var nbRows = parseInt (table.getRows ()); var tableAbsLocator = table.getAbsoluteLocator (); While (nbRows)-{var rowCol = AdfPage.PAGE.findComponentByAbsoluteLocator (tableAbsLocator + "[" + nbRows + "]:" + colId);} NUM = num + rowCol.getValue (); } var outputText = inputTxt.findComponent (outId); outputText.setValue (num); } For more information, see this https://community.oracle.com/thread/3512479
: Nitesh
-
10g - how to get the total overall totals
I need to generate a report of sales of products and companies with 3 columns of running totals. The columns are the amounts of gross sales,
the commissions earned and net premiums (gross sales - commissions earned). As each item in the purchase order, a record (transaction.transaction_id) is created and also
inserted into the table transaction_link as FK (transaction_link.trans_settle_id). When transaction_link has all the elements necessary to complete the order, the seller receives
his commission and totals to add to the report.
Here are the tablesscrewdrivers gross premium commission net premium(gross - commission) philips 1000 300 700 sears 500 200 300 === === === screwdriver ttl 1500 500 1000 power drills dewalt 1000 300 700 makita 600 200 400 === === === power drill ttl 1600 500 1100 grand total 3100 1000 1100
provider - prov_id (pk)
PRODUCT_TYPE - prod_type_id (pk)
transaction-transaction_id (pk), amount, dealer_commission
transaction_link - trans_settle_id, trans_trade_id, trans_type
I'm using the With clause, if I understand correctly it is very effective, but all the other tips are welcome:
net premium of the gross premium commission (gross-commission)WITH getSettlementTransaction AS (SELECT transaction_id FROM transaction trans WHERE trans.trans_type_id = 9 AND trans.PROV_ID = 25 AND trans.TRADE_DATE BETWEEN '1-SEP-05' AND TRUNC(SYSDATE)+1 ), getWireTransaction AS (SELECT trans_trade_id, trans_settle_id, trans.prov_id, prov.prov_name, trans.amount, trans.dealer_commission, trans.prod_type, prod.product_type FROM transaction_link, transaction trans, provider prov, product_type prod WHERE trans_link_type_id = 3 AND trans.transaction_id = transaction_link.trans_trade_id AND prov.PROV_ID = trans.PROV_ID AND trans.prod_type = prod.product_type_id AND trans.TRADE_DATE BETWEEN '1-SEP-05' AND TRUNC(SYSDATE)+1 ) SELECT prov_name, product_type, SUM(amount) gross_premium, SUM(dealer_commission) commission_earned , SUM(amount) - SUM(dealer_commission) FROM getWireTransaction, getSettlementTransaction WHERE trans_settle_id = transaction_id GROUP BY prov_name, product_type;
Philips 1000 700 300
Sears 500 200 300
But it doesn't give me the total for each vendor and does not include totals as I need.
Any guidance would be appreciated. Thank you.Hello
Achtung wrote:
It's great! Is it possible to format?DEPTNO:10 ENAME SAL --------------- ---------- CLARK 2450 KING 5000 MILLER 1300 Dept. Total 8750 DEPTNO:20 ADAMS 1100 FORD 3000 JONES 2975 SCOTT 3000 SMITH 800 Dept. Total 10875 DEPTNO:30 ALLEN 1600 BLAKE 2850 JAMES 950 MARTIN 1250 TURNER 1500 WARD 1250 Dept. Total 9400 Grand Total 29025
I don't know how to make a line like "DEPTNO:10" before the header. It was maybe just a typo.
GROUP OF ROLLUP (or GROUP BY GROUPING SETS) will produce an great aggregate (such as 'Dept 9400 Total') line for each distinct value of the column rolled up. It looks like you want two of these lines: one at the beginning of each Department ("DEPTNO:30") and the other at the end ("min. Total 9400'). I don't know if you can get in a single subquery with GROUP BY. You can get it without a doubt with the UNION.
WITH union_results AS ( -- This branch of the UNION produces the header row for each department -- (and also the blank row before the grand total) -- SELECT deptno AS raw_deptno , CASE WHEN GROUPING (deptno) = 0 THEN 'DEPTNO: ' || deptno END AS display_deptno , NULL AS ename , NULL AS sal , 1 AS group_num FROM scott.emp GROUP BY ROLLUP (deptno) -- UNION ALL -- -- This branch of the UNION produces the rows for each employee, and the "Total" rows -- SELECT deptno AS raw_deptno , NULL AS display_deptno , CASE WHEN GROUPING (deptno) = 1 THEN ' Grand Total' WHEN GROUPING (ename) = 1 THEN ' Dept. Total' ELSE ename END AS ename , SUM (sal) AS sal , CASE WHEN GROUPING (ename) = 0 THEN 2 ELSE 3 END AS group_num FROM scott.emp GROUP BY ROLLUP (deptno, ename) ) SELECT display_deptno AS deptno , ename , sal --, group_num FROM union_results ORDER BY raw_deptno , groUp_num , ename ;
Results:
DEPTNO ENAME SAL ------------ --------------- ---------- DEPTNO: 10 CLARK 2450 KING 5000 MILLER 1300 Dept. Total 8750 DEPTNO: 20 ADAMS 1100 FORD 3000 JONES 2975 SCOTT 3000 SMITH 800 Dept. Total 10875 DEPTNO: 30 ALLEN 1600 BLAKE 2850 JAMES 950 MARTIN 1250 TURNER 1500 WARD 1250 Dept. Total 9400 Grand Total 29025
The subquery is needed only to hide a part of the ORDER BY columns.
You can comment the group_num column in the SELECT clause, to see how it works.
Maybe you are looking for
-
I just upgraded the OS to El Capitan v 10.11.5. My (5 TB) ntfs disk won't mount. Tried through the application disk utility and also diskutil command in the Terminal. Everyone knows the same?
-
BIOS resets on Satellite 1410 304
How to reset the BIOS of Satellite S1410-304?
-
Lenovo Ideapad U550 Driver for Windows 8
I'm looking for the Ideapad U550 Windows 8 drivers, after update from Windows 7 to Windows 8. It works, but some things don't. The graphics card and does not work and also the camera is not supported. Would be happy to help, or even all of the necess
-
How can I remove searchplugins
Please help me remove searchplugins which shows always on my desktop and files
-
Original title: Why do I get a message that a Total Training Adobe project file cannot be opened because it is not a valid Win32 application? I can't open a file PF.zip of the learing Adobe Total Training Library. I should be able to double-click on