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 article, if it is
applicable:
http://www.sqlite.org/cvstrac/wiki?p=ScrollingCursor

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 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 ten.
>>
>> This only displays the last code + total number of rows in the table:
>> SELECT code,COUNT(code) FROM companies ORDER by COUNT(code) DESC;
>>
>> This shows the same output:
>> SELECT code,COUNT(code) FROM boites ORDER BY code DESC;
>>
>> Any idea how to do this?
>>
>> Thank you for any tip.
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to