SQLite3

  1. Get the row numbers after group or select the query.
    select count(*) as rows from (select * from database group by query)