Convert Java 8 lambdas to SQL statements