Re: Query question.

From: Matthew D. Bennett <mbennett_at_utah-inter.net>
Date: Thu, 06 Dec 2001 12:36:21 -0700
Message-ID: <3C0FC8A6.1B7248DE_at_utah-inter.net>


Peter,

[Quoted] Try the following SELECT statement:

SELECT customerID, sum(OrderAmount)
FROM TABLENAME
GROUP BY CustomerID;

Matt.

Peter wrote:
>
> Hi,
>
> Say I have a table with OrderID, CustomerID and OrderAmount (and more item)
> with OrderID as pk, each customer(CustomerID) can have more than one orders,
> if I want to get the list of (distinct) CustomerID and OrderAmount which the
> accumulated OrderAmount for that customer is more than a certain number,
> what the query should be?
>
> Sample table:
>
> OrderID CustomerID OrderAmount
> --------- ------------ --------------
> 1 100 10
> 2 101 9
> 3 100 6
> 4 102 13
> 5 101 11
> .....
>
> I want output of:
>
> CustomerID Total OrderAmount
> ------------ ---------------------
> 100 16
> 101 20
> 102 13
> ....
>
> Thanks,
> Barry
Received on Thu Dec 06 2001 - 20:36:21 CET

Original text of this message