1、oracle/mysql 实用语句

where/and|or/betwwen-and/like/order dy(asc/desc)/count(1)/group by having/

1、分页
select * from(select t.* ,rownum n from SF_OPERATORLOG t )where n between 10 and 19;
select * from (select t.*,rownum n from sf_operatorlog t where rownum<20 )where n>=10;
一般实用第二种

  select p.* from (select rownum rm,t1.* from (select t.logid,t.logdatetime,t.logcomment from st_log t  where t.opertype='2'and t.userid='DF05EB075F4B4FE39EE9BFF69C08EC06' order by t.logdatetime desc) t1 ) p where rm>=1 and rm<11

2、统计
   统计重复数据(依name)
   select t.*, count(1) from s_repeat t group by t.name;
   统计重复数据大于1的数据(group by 后用having 不是where)
   select t.*, count(1) from s_repeat t group by t.name having count(1)>1;

   统计重复数据(依所用字段)
   select t.* ,count(1) from s_repeat t group by t.name,t.id;
   select t.* ,count(1) from s_repeat t group by t.name,t.id having count(1)>1;
 
3、删除重复数据
   oracle:
   mysql:





你可能感兴趣的:(oracle)