根据日期判断生日:
SQL> select t.xm,t.sjhm,to_char(t.csrq,'MM-DD') sr from
birth_tx t where to_date(to_char(t.csrq,'MM-DD'),'MM-DD')
>= to_date(to_char( trunc(sysdate),'MM-DD'),'MM-DD') and rownum <10;
XM SJHM SR
-------------------- --------------- -----
张寅寅 13911835819 09-17
李振霞 13601287767 04-21
马晓萌 13911835838 05-28
刘为 13911899815 11-10
李学民 13501120961 10-23
王喆 13511021477 07-16
王永清 13911091901 06-23
孙大伟 13901036723 05-02
王志宽 13311067029 05-08
9 rows selected
SQL> select t.xm,t.sjhm,t.csrq from birth_tx t
2 where to_date(to_char(t.csrq,'MM-DD'),'MM-DD') < to_date(to_char( trunc(sysdate+1),'MM-DD'),'MM-DD')
3 and rownum <10;
XM SJHM CSRQ
-------------------- --------------- -----------
丛涛 13910991097 1978/2/12
梁立松 13911835827 1972/2/28
赵晶 13611086909 1962/3/2
马威 13911671567 1980/2/13
陈洪福 13901303007 1958/2/2
孟繁强 13911993728 1966/1/25
张国顺 13911257837 1956/2/13
宗康健 13911839524 1984/1/29
朱华 13911934599 1983/2/3
9 rows selected
SQL> select t.xm,t.sjhm,t.csrq from birth_tx t
2 where
3 to_date(to_char(t.csrq,'MM-DD'),'MM-DD') >= to_date(to_char( trunc(sysdate),'MM-DD'),'MM-DD')
4 and
5 to_date(to_char(t.csrq,'MM-DD'),'MM-DD') < to_date(to_char( trunc(sysdate+1),'MM-DD'),'MM-DD')
6 and rownum <10;
select t.xm,t.sjhm,t.csrq from birth_tx t
where
to_date(to_char(t.csrq,'MM-DD'),'MM-DD') >= to_date(to_char( trunc(sysdate),'MM-DD'),'MM-DD')
and
to_date(to_char(t.csrq,'MM-DD'),'MM-DD') < to_date(to_char( trunc(sysdate+1),'MM-DD'),'MM-DD')
and rownum <10
ORA-01839: 指定月份的日期无效
求大神指导啊?