You are here: Re: sql statement to select customers contributing top 60% of sales « MsSQL Server « IT news, forums, messages
Re: sql statement to select customers contributing top 60% of sales

Posted by Bill on 10/18/06 13:58

Try something of the format:

SELECT cs.cus_id, cs.cus_name, sum(sales) as sales
FROM cus_sales cs
INNER JOIN ( SELECT sum(sales) tot_sales FROM cus_sales ) ts
ON cs.sales >= ts.tot_sales * .6

kansaskannan@gmail.com wrote:
> I have an Access 2000 database which lists customers by name, and how
> much (in dollars) they have purchased of various products. How do I
> write a SQL statement to select customers who make up the top 60% of
> total sales dollars? I need to have a list of customers returned.
>
> The list of customers that get returned will be used to select other
> data from the same database. (I mention this in case there are multiple
>
> ways of getting the customer list).
>
>
> Thank you for any advice.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация