List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:March 27 2006 6:00pm
Subject:Re: Summing tables and fields Please help,,,
View as plain text  
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
>

Attachment: [text/html]
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
Thread
Summing tables and fields Please help,,,Brian E Boothe27 Mar
  • Re: Summing tables and fields Please help,,,Peter Brawley27 Mar