How to select records by nth minimum/maximum value of date column in postgresql? I have a table as follow:  

create table x(id int, work date);  


this table has the following records:  

insert into x values(1,'2017-01-01'),(2,'2017-01-01'),(3,'2017-02-02'),(4,'2017-01-15'),(5,'2017-01-15');  


Now, I want to select the records with first, second and third date values.
My desired output would be as follows:
If I want to select record with first date value then the output would be:  

id      work  
1     2017-01-01  


If I select record with second date value then the output would be:  

id      work  
 4    2017-01-15  


Any help is appreciated in advanced.
Another way:

SELECT *
FROM x
WHERE work = (SELECT DISTINCT work FROM x ORDER BY 1 OFFSET 1 LIMIT 1)
ORDER BY id
LIMIT 1;


Or more simpliest:

SELECT DISTINCT on (work)
       work, id
FROM x
ORDER BY 1, 2
OFFSET 1
LIMIT 1;


You can choose num of element by changing offset.