Fixed small error in SQL query - fixes #181