×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Ah, SQL with my coffee...

WITH ProductCounts as (SELECT client,
count(distinct product) as productCount
FROM qtemp/david
GROUP BY client
)
SELECT productCount, count(*) as clientCount
FROM ProductCounts
group by productCount


HTH,
Charles

On Thu, Sep 2, 2010 at 8:32 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Hi all,

I have a table like so :

Client Product
C1              P1
C1              P2
C2              P1
C3              P4
C4              P1
C4              P2
C4              P3

With the max, min and avg functions I can see that on average a client has 2 products, that no client has more than 7 products and none with less than 1.

But how can I output :

Number of products      Number of clients
1                               ?
2
3
4
5
6
7


Thanks.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.