From: Peter Brawley Date: March 27 2006 6:00pm Subject: Re: Summing tables and fields Please help,,, List-Archive: http://lists.mysql.com/mysql/196207 Message-Id: <4428283A.4040008@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-4428283B1C6F=======" --=======AVGMAIL-4428283B1C6F======= Content-Type: multipart/alternative; boundary=------------070200030509030100050502 --------------070200030509030100050502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Brian, >can someone post a snippit on Summing tables together of a feild of the >entire Database ? Do you mean summing all row values of a column in a table, grouped by the value of another column? If so, for example to retrieve all electprojcost, electprojbilling values and their differences per projectname would be ... SELECT projectname, SUM(electprojcost), SUM(elecprojbilling), SUM(elexprojcost-electprojbilling) AS margin FROM orders GROUP BY projectname; Or do you mean something else? PB ----- Brian E Boothe wrote: > can someone post a snippit on Summing tables together of a feild of the > entire Database ? why does everyone Have such a problem with this > question? everyone i ask says the same thing,, let me show what i'm > needing by Visual representation > MySQL database >> workorders > Table : Orders > Field(aa) ProjectName -- [enter Projectname] > Field [a] ElecprojCost ----- <-Enter in Number > Field [b] ElecprojBilling -----<-Enter in Number > Field [c] Elecprojremaining = [a] - [b] > Field [d] CtrlprojCost ----- <-Enter in Number > Field [e] CtrlprojBilling ----- <-Enter in > Number > Field [f] Ctrlprojremaining = [d] - [e] > Field [g] OtherprojCost ----- <-Enter in > Number > Field [h] OtherprojBilling ----- <-Enter > in Number > Field [i] Otherprojremaining = [g] - [h] > Field [j] BondedAmount = <-Enter in Number > Field [k] Bondedprogbilling = <-Enter in Number > Field [l] Bondedprogremaining = <-= [j] - [ k ] > Field [m] totalelecworkonhand = <-sum of all remaining = (sum of C > all sum records for Values of (C) > Field [n] totalCtrlworkonhand = <-sum of all remaining = (sum of F > all sum records for Values of (F) > Field [o]totalOtherworkonhand = <-sum of all remaining = (sum of i > all sum records for Values of (i) > Field [p] totalworkonhand = m + n + o > Field [Q] totalBondedworkonhand = sum of all remaining = (sum of > P all sum records for Values of (P) > > Any help in all this would be greatly appreaciated,, u > can also email me via subrian@stripped > --------------070200030509030100050502 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
>can someone post
a snippit
on Summing tables together of a feild of the
>entire Database ?
Do you mean summing
all row
values of a column in a table, grouped by the value of another column?
If so, for example to
retrieve all electprojcost, electprojbilling values and their
differences per
projectname would be ...
SELECT
projectname,
SUM(electprojcost),
SUM(elecprojbilling),
SUM(elexprojcost-electprojbilling)
AS margin
FROM orders
GROUP BY projectname;
Or
do you mean something else?
PB
can someone post a snippit on Summing tables together of a feild of the--------------070200030509030100050502-- --=======AVGMAIL-4428283B1C6F======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.3.2/293 - Release Date: 3/26/2006 --=======AVGMAIL-4428283B1C6F=======--
entire Database ? why does everyone Have such a problem with this question? everyone i ask says the same thing,, let me show what i'm needing by Visual representation
MySQL database >> workorders
Table : Orders
Field(aa) ProjectName -- [enter Projectname]
Field [a] ElecprojCost ----- <-Enter in Number
Field [b] ElecprojBilling -----<-Enter in Number
Field [c] Elecprojremaining = [a] - [b]
Field [d] CtrlprojCost ----- <-Enter in Number
Field [e] CtrlprojBilling ----- <-Enter in Number
Field [f] Ctrlprojremaining = [d] - [e]
Field [g] OtherprojCost ----- <-Enter in Number
Field [h] OtherprojBilling ----- <-Enter in Number
Field [i] Otherprojremaining = [g] - [h]
Field [j] BondedAmount = <-Enter in Number
Field [k] Bondedprogbilling = <-Enter in Number
Field [l] Bondedprogremaining = <-= [j] - [ k ]
Field [m] totalelecworkonhand = <-sum of all remaining = (sum of C all sum records for Values of (C)
Field [n] totalCtrlworkonhand = <-sum of all remaining = (sum of F all sum records for Values of (F)
Field [o]totalOtherworkonhand = <-sum of all remaining = (sum of i all sum records for Values of (i)
Field [p] totalworkonhand = m + n + o
Field [Q] totalBondedworkonhand = sum of all remaining = (sum of P all sum records for Values of (P)
Any help in all this would be greatly appreaciated,, u can also email me via subrian@stripped