Fixed SQL query for one-row-tables.