SQL rewrited gor derbyDB