2

DB2で休止状態を使用していますが、次の問題があります。テーブル/エンティティには、Customerフィールド、、first_name()があります。次の4日間に誕生日を迎えるすべての顧客を取得するクエリを作成する必要があります。問題は、一部の顧客の場合、生年が不明であるため、データベースで9999に設定されているため、where句で単純なチェックを行うことができないことです(9999年のため)。last_namebirthdayjava.util.Date

4

1 に答える 1

1

シンプルな hql クエリの使用

from Customer as user where month(user.birthday) = month(current_date()+4 days) and day(user.birthday) = day(current_date()+4 days)
union all
from Customer as user where month(user.birthday) = month(current_date()+3 days) and day(user.birthday) = day(current_date()+3 days)
union all
from Customer as user where month(user.birthday) = month(current_date()+2 days) and day(user.birthday) = day(current_date()+2 days)
union all
from Customer as user where month(user.birthday) = month(current_date()+1 day) and day(user.birthday) = day(current_date()+1 day)
于 2012-08-31T17:36:37.410 に答える