select telno from tablename group by telno having count(*)=1
解决方案 »
- add debug information
- java.sql.BatchUpdateException: 批处理中出现错误: ORA-00972: 标识符过长
- 求教多表查找关键字的方法
- Convert(varchar(10),aa,21)
- 如何做RMAN热备份的恢复
- 关于ORACLE自动插入数据的问题
- SQL问题,关于DISTINCT COUNT() 。。感谢帮助。。
- database服务器换IP
- 监听器的问题
- windows2000 client oem console 无法连接到redhat7.2 oracle 问题
- 有了解oracle9i数据库复制技术的吗,能聊聊和8i比起来有哪些增强吗?
- 怎么样将长字符串(>4000)更新到long 类型的字段中
distinct 函数可忽略重复值。如想限制4月到6月可在条件后加上‘to_date(feemonth,'yyyymm') between to_date('200304','yyyymm') and to_date('200307','yyyymm')’
from cw_tb t1,cw_tb t2
where t1.telno = t2.telno and t1.feemonth = to_char(add_months(to_date(t2.feemonth||'01','YYYY-MM-DD'),1),'YYYYMM') and t1.flag > 1 and t2.flag > 1;解决问题:查出两个月以上连续flag>1!
FROM TABLENAME T1,TABLENAME T2
WHERE T1.TELNO=T2.TELNO
AND T1.FLAG>=2
AND T2.FLAG>=2
AND TO_NUMBER(TO_DATE(T1.FEEMONTH,'YYYY-MM-DD')-T0_DATE(T2.FEEMONTH,'YYYY-MM-DD')=1
(select telno,flag-lead(flag,1,0) over(order by feemonth desc) num,flag from tabname order by feemonth desc)
where num=1 and flag=2