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 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