Repaired sql to work with hsqldb