The fields used in the conditions are swapped. The lending date is always recorded when an item is lent out, so it never becomes null, and this condition would extract almost nothing. Furthermore, “the return date is within 2 weeks from the investigation date” is a condition that picks records that already have a return date, that is, ones already returned, which is the opposite direction from the goal of finding people who have not returned anything.
×Incorrectイ
It has only the deadline condition “the lending date is 2 or more weeks before the investigation date” and does not ask whether the item is still unreturned. As a result, records of employees who borrowed more than 2 weeks ago but have already properly returned the item are also included, so even people who should not be contacted get extracted.
○ウ
正解What we want is employees who have not returned the item yet and whose loan has also gone past 2 weeks, so two extraction conditions are needed. The first is that the item is not returned. In the lending table, a date is set in the return date when the return is processed, so a record whose return date is still null is one that has not come back yet. The second is that the deadline has passed. Being more than 2 weeks counting from the lending date inclusive means that the lending date is 2 or more weeks before the investigation date. Choice ウ joins these two with “and”, extracting records where the return date is null and the lending date is 2 or more weeks before the investigation date, so it picks out exactly the applicable people, no more and no less. This is a typical example of what a relational database calls “selection” (the operation of narrowing down to only the rows that meet a condition), carried out with multiple conditions combined by AND.
×Incorrectエ
“The return date is null” is correct as a condition for not yet returned, but the deadline condition is missing. An employee who borrowed only yesterday and is still within the return period is also unreturned, so they too would enter the extraction results, and it cannot narrow the list down to only those who have gone past 2 weeks.
ここがポイント
When designing extraction (selection) conditions, translate the requirement given in words into conditions on fields one by one and count them up. “Not returned yet” = the return date is null; “more than 2 weeks counting from the lending date inclusive” = the lending date is 2 or more weeks before the investigation date; then join the two with “and” (AND).
If one condition is missing, unnecessary records get mixed into the result, and if the field used in a condition is mistaken, the needed records cannot be obtained. Also keep in mind that a null value (a state where no value has been set) is used as a mark showing that the corresponding processing has not been done yet.