반응형
/********************************************************************************
-- Title : [PGS9.2] Paging using LIMIT and OFFSET
-- Reference : postgresql.org
-- Key word : paging limit offset 페이징 top(n) top
********************************************************************************/
-- initiate table
drop table ttt;

-- create table
create table ttt
(a int, b varchar(100));

-- insert data
insert into ttt
select generate_series, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
from generate_series(1,1000, 1);

-- select data
select * from ttt;

-- limit (x)
-- similar to TOP (N) on SQL Server 
select *
from ttt
limit 10;

-- offset (x)
select *
from ttt
offset 5;

-- limit & offset
select *
from ttt
limit 15
offset 10;






반응형

+ Recent posts