I'm no expert, but I'd do it with: SELECT COUNT(*) AS count FROM ratingsTable GROUP BY mtId ORDER BY count DESC LIMIT 1;
:-David Burström On 01/25/2011 03:49 PM, Puneet Kishor wrote: > > Ian Hardingham wrote: >> Hey guys. >> >> I have the following table: >> >> ratingsTable (id INTEGER PRIMARY KEY AUTOINCREMENT, mtId INTEGER, user >> TEXT, rating INTEGER); >> >> mtId links to another table's primary key >> >> I wish to have a query which gives me the mtId which is represented most >> often in the ratingsTable. >> >> Does anyone have any advice? > > a combination of Max() and Count() > > Puneet. > _______________________________________________ > 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