Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with SUM 1

Status
Not open for further replies.

dmears1

Technical User
Jun 18, 2003
208
US
I need to pull info from 2 tables and then do a summation on one of the returned rows. Here is the SELECT statement I have which does pull the info I need:
Code:
SELECT orders.orders_id, orders.date_purchased, orders_total.class, orders_total.orders_id, orders_total.value
FROM orders, orders_total
WHERE orders.orders_id = orders_total.orders_id AND orders_total.class = 'ot_total' AND orders.date_purchased
LIKE '2004-07%'
How can I do a SUM on the orders_total.value column? I thought I could do this using CREATE VIEW but then realized that you must have MySQL v5 to use CREATE VIEW.
Thanks in advance for any help.

 
Code:
SELECT sum(orders_total.value) as total_value
  FROM orders
inner
  join orders_total
    on orders.orders_id 
     = orders_total.orders_id 
   and orders_total.class = 'ot_total' 
 where orders.date_purchased >= '2004-07-01'
   AND orders.date_purchased  < '2004-08-01'

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top