SQL语句要实现的是统计今天上线的手机号码是昨天没有上线过的,也就是新的用户
SQL语句如下:
select substr(to_char(a.freq_time,'yyyymmddhh24miss'),1,8),count(distinct a.fsend_mobile) from (select freq_time,fsend_mobile from tsms_uphislog where not exists(select fsend_mobile from tsms_uphislog where (fori_addr='31687777004' or fori_addr='31687777005') and (fmsg_content='1' or fmsg_content='2' or fmsg_content='3' or fmsg_content='4') and freq_time>=to_date('20060901','yyyymmdd') and freq_time<to_date('20060902','yyyymmdd')) and freq_time>=to_date('20060902','yyyymmdd') and freq_time<to_date('20060903','yyyymmdd') and (fori_addr='31687777004' or fori_addr='31687777005') and (fmsg_content='1' or fmsg_content='2' or fmsg_content='3' or fmsg_content='4')) a group by substr(to_char(a.freq_time,'yyyymmddhh24miss'),1,8)
这条语句查询不到数据,但实际上数据库是有数据的
自己怀疑是exists的用法问题,但解决不了
各位大侠赐教!!!
SQL语句如下:
select substr(to_char(a.freq_time,'yyyymmddhh24miss'),1,8),count(distinct a.fsend_mobile) from (select freq_time,fsend_mobile from tsms_uphislog where not exists(select fsend_mobile from tsms_uphislog where (fori_addr='31687777004' or fori_addr='31687777005') and (fmsg_content='1' or fmsg_content='2' or fmsg_content='3' or fmsg_content='4') and freq_time>=to_date('20060901','yyyymmdd') and freq_time<to_date('20060902','yyyymmdd')) and freq_time>=to_date('20060902','yyyymmdd') and freq_time<to_date('20060903','yyyymmdd') and (fori_addr='31687777004' or fori_addr='31687777005') and (fmsg_content='1' or fmsg_content='2' or fmsg_content='3' or fmsg_content='4')) a group by substr(to_char(a.freq_time,'yyyymmddhh24miss'),1,8)
这条语句查询不到数据,但实际上数据库是有数据的
自己怀疑是exists的用法问题,但解决不了
各位大侠赐教!!!
關鍵字是你數據庫唯一標識的字段