Fixed SQL query for SQLite. Fixes #14.