nerdexam
Oracle

1Z0-900 · Question #68

Given the JPQL code fragment: Select pub.title, pub.author, pub.pages FROM Publisher pub Which two clauses do you add to this JPQL query to retrieve only those books with between 500 and 750 total…

Option C (WHERE pub.pages BETWEEN 500 AND 750) is the correct clause for this filter. JPQL's BETWEEN keyword is inclusive on both ends, so it retrieves rows where pub.pages >= 500 AND pub.pages <= 750 - exactly the range required - in a single, readable expression. Why the…

Manage Persistence using JPA Entities and BeanValidation

Question

Given the JPQL code fragment:

Select pub.title, pub.author, pub.pages FROM Publisher pub Which two clauses do you add to this JPQL query to retrieve only those books with between 500 and 750 total pages? (Choose two.)

Options

  • AWHERE MIN(pages) >= 500 AND MAX(pages) <= 750
  • BWHERE pub.pages <= 500 OR pub.pages >= 750
  • CWHERE pub.pages BETWEEN 500 AND 750
  • DWHERE pub.pages <= 500 AND pub.pages >=750

Explanation

Option C (WHERE pub.pages BETWEEN 500 AND 750) is the correct clause for this filter. JPQL's BETWEEN keyword is inclusive on both ends, so it retrieves rows where pub.pages >= 500 AND pub.pages <= 750 - exactly the range required - in a single, readable expression.

Why the others fail:

  • A misuses aggregate functions (MIN, MAX) in a WHERE clause; those belong in a HAVING clause and operate on grouped sets, not individual rows.
  • B inverts the logic with OR - it returns pages outside the range (500 or below, 750 or above), the opposite of what's needed.
  • D is a logical impossibility: no single integer can be both <= 500 AND >= 750 simultaneously, so this clause returns zero rows.

Note: The question says "choose two," but only C is valid among the listed options - the second correct answer (likely WHERE pub.pages >= 500 AND pub.pages <= 750) appears to be missing from the choices provided.

Memory tip: Think of BETWEEN low AND high as a closed gate - both posts (500 and 750) are included. If you ever see OR in a range filter, that's a red flag: ranges always use AND.

Topics

#JPQL WHERE clause#BETWEEN operator#Range filtering#JPA queries

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice