SELECT * FROM (
SELECT birthday , month(current_date() ) nowmonth ,month(date_add(current_date(),5)) nextmonth ,month(to_date(birthday)) usermonth , day(current_date() ) nowday ,day(date_add(current_date(),5)) nextday
, day(to_date(birthday)) userday from tablename
)
WHERE
(
nowmonth != nextmonth AND
(
(nowmonth== usermonth AND userday> nowday )
or (nextmonth == usermonth AND userday <= nextday )
)
)
OR (nowmonth == nextmonth AND userday > nowday AND userday <=nextday )
;
【无标题】SQL+HIVE 题目:查询接下来5天要过生日的学生
最新推荐文章于 2024-07-15 19:29:53 发布