Off the top of my head:

SELECT
        count(status) as totalOrders,
        status,
        sum(price * quantity) as totalRevenue
FROM
        store_orders
WHERE
        merc_id = 1
GROUP BY status

This will give you the count of total orders in each status with the  
total revenue associated with each status.

Of course, this is off the top of my head so the syntax may not be 100%  
correct....

-dhs



On Friday, February 21, 2003, at 09:00  PM, Owens, Howard wrote:

> I'm trying to come up with a query that will tell me:
>
> 1) How many orders have been place
> 2) What the total income from those orders ad up to.
>
> I tried this, but it isn't giving me what I expect:
>
> SELECT     COUNT(STATUS) AS TotalOrders, PRICE * QUANTITY AS Revenue
> FROM         store_orders
> WHERE     (MERC_ID = 1)
> GROUP BY PRICE, QUANTITY
>
> That would be the simple way of doing ...
>
> Alternatively, I would like the query to break down the same  
> information
> based on STATUS (pending, paid, shipped, etc), along with total  
> aggregrate.
>
> Any pointers would be appreciated.
>
> H.
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Howard Owens
> Internet Operations Coordinator
> InsideVC.com/Ventura County Star
> [EMAIL PROTECTED]
> AIM: GoCatGo1956
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
Get the mailserver that powers this list at http://www.coolfusion.com

                        

Reply via email to