Re: New to SQL
Date: 1995/11/30
Message-ID: <DIvHxC.CG8_at_txnews.amd.com>#1/1
> Hi !
>
> I have a problem. I'm trying to write a SQL statement to recive alla
> customers names for the 6000 best customers who has bought articels
> during 1995.
> My two databas tabels looks like this
> Customer Order
> ___________ ____________
> customerID CustomerID
> Name TotalAmount (since the customer became a customer in > the system)
> OrderNumber
> ShipedDate
>I would be very glad if someone could help me with this.
> Jost Werdenhoff
> Mda94jwe_at_rby.hk-r.se
I don't quite understand your table definitions. If total amount is the cumulative amount, then how can you have multiple orderno.and shipped date in the same row ?
Assuming total_amount to be a cumulative staement: (One record per customer in Order table) Try the following statement:
Select a.name, b.totalamount
from customer a, order b
where a.customerid=b.customerid
and 59 < (select count(*) from
order c where c.totalamount > b.totalamount and c.customerid <> b.customerid)
Hope this solves your problem.
Cheers,
Suman. Received on Thu Nov 30 1995 - 00:00:00 CET