Fixed stats queries for sqlite

Change-Id: I381f6991652ac209fc7de520e697178fcb7f51f6