Re: [sqlite] Listing top 10 companies through COUNT?

2008-11-23 Thread Gilles Ganault
On Sun, 23 Nov 2008 16:40:11 +0800, "Eugene Wee" <[EMAIL PROTECTED]> wrote: >Oops, and as for top 10, a LIMIT 10 clause may suffice, e.g., >SELECT code, COUNT(code) AS code_count FROM companies GROUP BY code ORDER BY >code_count DESC LIMIT 10; > >However, if you wish to show the next 10, then the

Re: [sqlite] Listing top 10 companies through COUNT?

2008-11-23 Thread Eugene Wee
Oops, and as for top 10, a LIMIT 10 clause may suffice, e.g., SELECT code, COUNT(code) AS code_count FROM companies GROUP BY code ORDER BY code_count DESC LIMIT 10; However, if you wish to show the next 10, then the next 10, etc, then you might consider the technique described in this wiki

Re: [sqlite] Listing top 10 companies through COUNT?

2008-11-23 Thread Eugene Wee
Hi, It sounds like you want a GROUP BY clause, e.g., SELECT code, COUNT(code) AS code_count FROM companies GROUP BY code ORDER BY code_count DESC; Regards, Eugene Wee On Sun, Nov 23, 2008 at 4:16 PM, Gilles Ganault <[EMAIL PROTECTED]>wrote: > Hello > >I tried a few things, but I still

[sqlite] Listing top 10 companies through COUNT?

2008-11-23 Thread Gilles Ganault
Hello I tried a few things, but I still can't find how to do this: The Companies table contains one row for each company; each row has a Code field that indicates the type of activity this company is into. I'd like to count how many companies belong to each activity, and display the top