`
chaochaoyuyu
  • 浏览: 53753 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

oracle 自增序列及分组查询取某一条(row_number()函数)

 
阅读更多
-- Create sequence 
create sequence SEQ_C_PICRECORD
minvalue 1
maxvalue 9999999999
start with 21
increment by 1
cache 20;

--Create trigger
create or replace trigger tri_c_picrecord
before insert on c_picrecord for each row
begin
  select seq_c_picrecord.nextval into:new.id from dual;
end;

 

select *
  from (select t.*,
               row_number() over(partition by car_num, car_numcolor order by cap_date) as rn from
  c_picrecord t) a
 where a.rn = 3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics