I have a table with ID (IP address) and a factor variable (Web browser) and I need to make another table that has a single record for each ID, together with the mode of the factor variable. I was thinking of something like SELECT ip, MODE (browser) FROM log GROUP BY ip
.
Unfortunately, SQLite doesn't implement a MODE
function, so this doesn't work. I thought of building a temporary table with the counts of each browser and then using a SELECT DISTINCT ON
or a RANK ()
statement but SQLite doesn't support these either.
Additionally, it would be nice to this in a single statement because there are several other factors whose mode I also need (and are also grouped by the same ID).