List:General Discussion« Previous MessageNext Message »
From:Scott Haneda Date:December 28 2005 2:40am
Subject:Re: Grand summary
View as plain text  
on 12/27/05 6:25 PM, Scott Haneda at lists@stripped wrote:

> I have two tables, order and order items.  An order can have 1 or more order
> items.
> 
> Important data in order is the `id` which is the key to link that order to
> the order_items table.
> 
> Quantity of items is stored in the order_items table.
> 
> I need to select the below data, and would like to do it in one select, and
> not use server side code to add it all up:
> 
> Total Number of Orders (count order records)
> Total Products $ (sum of qty and price in order_items)
> Total Shipping $ (sum of shipping field in order record)
> Total Gift Card $ (sum of gift card price in order record)
> Total Tax $ (sum of sales tax in order record)
> Total Orders: $ (grand summary of total in order record)

Sorry for the noise, turns out I did not need this at all, and can just use
sum() and no need for the join at all.
-- 
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
<http://www.newgeo.com>                     Novato, CA U.S.A.


Thread
Grand summaryScott Haneda28 Dec
  • Re: Grand summaryScott Haneda28 Dec